Changeset 3076
- Timestamp:
- Oct 6, 2023, 5:32:11 PM (16 months ago)
- Location:
- trunk
- Files:
-
- 12 edited
- 11 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/abort_pem_mod.F90
r3075 r3076 1 ! 2 ! $Id: abort_pem.F 3 ! 4 c 5 c 6 SUBROUTINE abort_pem(modname, message, ierr) 7 1 MODULE abort_pem_mod 2 3 implicit none 4 5 !======================================================================= 6 contains 7 !======================================================================= 8 9 SUBROUTINE abort_pem(modname,message,ierr) 10 8 11 #ifdef CPP_IOIPSL 9 USEIOIPSL12 use IOIPSL 10 13 #else 11 ! if not using IOIPSL, we still need to use (a local version of) getin_dump12 USEioipsl_getincom14 ! if not using IOIPSL, we still need to use (a local version of) getin_dump 15 use ioipsl_getincom 13 16 #endif 14 17 15 18 #ifdef CPP_XIOS 16 ! ug Pour les sorties XIOS 17 USE wxios 19 use wxios ! ug Pour les sorties XIOS 18 20 #endif 19 21 22 implicit none 23 20 24 #include "iniprint.h" 21 22 C23 C Stops the simulation cleanly, closing files and printing various24 C comments25 C26 C Input: modname = name of calling program27 C message = stuff to print28 C ierr = severity of situation ( = 0 normal )29 25 30 character(len=*), intent(in):: modname 31 integer, intent(in):: ierr 32 character(len=*), intent(in):: message 26 ! Stop the simulation cleanly, closing files and printing various comments 27 ! Input: modname = name of calling program 28 ! message = stuff to print 29 ! ierr = severity of situation (= 0 normal) 30 character(len = *), intent(in) :: modname 31 integer, intent(in) :: ierr 32 character(len = *), intent(in) :: message 33 33 34 write(lunout,*) 'in abort_pem' 34 !----- Code 35 write(lunout,*) 'in abort_pem' 35 36 36 37 #ifdef CPP_XIOS 37 !Fermeture propre de XIOS 38 CALL wxios_close() 38 CALL wxios_close() ! Fermeture propre de XIOS 39 39 #endif 40 40 41 41 #ifdef CPP_IOIPSL 42 43 42 call histclo 43 call restclo 44 44 #endif 45 call getin_dump 46 write(lunout,*) 'Stopping in ', modname 47 write(lunout,*) 'Reason = ',message 48 if (ierr .eq. 0) then 49 write(lunout,*) 'Everything is cool' 50 stop 51 else 52 write(lunout,*) 'Houston, we have a problem ', ierr 53 stop 1 54 endif 55 END 45 46 call getin_dump 47 write(lunout,*) 'Stopping in ', modname 48 write(lunout,*) 'Reason = ', message 49 if (ierr == 0) then 50 write(lunout,*) 'Everything is cool' 51 stop 52 else 53 write(lunout,*) 'Houston, we have a problem ', ierr 54 stop 1 55 endif 56 57 END SUBROUTINE abort_pem 58 59 END MODULE abort_pem_mod -
trunk/LMDZ.COMMON/libf/evolution/changelog.txt
r3070 r3076 89 89 == 05/10/2023 == JBC 90 90 Correction of a bug: the variable 'g' was not correctly initialized in 1D. A little of code cleaning. 91 92 == 06/10/2023 == JBC 93 Big cleaning/improvements of the PEM: 94 - Conversion of "abort_pem.F" and "soil_settings_PEM.F" into Fortran 90; 95 - Transformation of every PEM subroutines into module; 96 - Rewriting of many subroutines with modern Fortran syntax; 97 - Correction of a bug in "pem.F90" when calling 'recomp_tend_co2_slope'. The arguments were given in disorder and emissivity was missing; 98 - Update of "launch_pem.sh" in deftank. -
trunk/LMDZ.COMMON/libf/evolution/compute_tendencies_slope_mod.F90
r3075 r3076 1 MODULE compute_tendencies_slope_mod 2 3 implicit none 4 5 !======================================================================= 6 contains 7 !======================================================================= 8 1 9 SUBROUTINE compute_tendencies_slope(ngrid,nslope,min_ice_Y1,min_ice_Y2,tendencies_ice) 2 10 … … 18 26 ! OUTPUT 19 27 real, dimension(ngrid,nslope), intent(out) :: tendencies_ice ! physical point field : difference between the minima = evolution of perenial ice 20 21 28 !======================================================================= 22 29 … … 29 36 END SUBROUTINE compute_tendencies_slope 30 37 38 END MODULE compute_tendencies_slope_mod 39 -
trunk/LMDZ.COMMON/libf/evolution/conf_pem.F90
r3039 r3076 8 8 !======================================================================= 9 9 10 IMPLICIT NONE 10 implicit none 11 11 12 CONTAINS 12 !======================================================================= 13 contains 14 !======================================================================= 13 15 14 16 SUBROUTINE conf_pem(i_myear,n_myears) 15 17 16 18 #ifdef CPP_IOIPSL 17 use IOIPSL,only: getin19 use IOIPSL, only: getin 18 20 #else 19 ! if not using IOIPSL, we still need to use (a local version of) getin20 use ioipsl_getincom, only: getin21 ! if not using IOIPSL, we still need to use (a local version of) getin 22 use ioipsl_getincom, only: getin 21 23 #endif 22 23 use time_evol_mod, only: year_bp_ini, dt_pem, water_ice_criterion, co2_ice_criterion, ps_criterion, Max_iter_pem, &24 evol_orbit_pem, var_obl, var_ecc, var_lsp, convert_years25 use comsoil_h_pem, only: soil_pem, fluxgeo, water_reservoir_nom, depth_breccia, depth_bedrock, reg_thprop_dependp26 use adsorption_mod, only: adsorption_pem27 use glaciers_mod, only: co2glaciersflow, h2oglaciersflow28 use ice_table_mod, only: icetable_equilibrium, icetable_dynamic29 24 30 integer, intent(out) :: i_myear, n_myears ! Current simulated Martian year and maximum number of Martian years to be simulated 25 use time_evol_mod, only: year_bp_ini, dt_pem, water_ice_criterion, co2_ice_criterion, ps_criterion, Max_iter_pem, & 26 evol_orbit_pem, var_obl, var_ecc, var_lsp, convert_years 27 use comsoil_h_pem, only: soil_pem, fluxgeo, water_reservoir_nom, depth_breccia, depth_bedrock, reg_thprop_dependp 28 use adsorption_mod, only: adsorption_pem 29 use glaciers_mod, only: co2glaciersflow, h2oglaciersflow 30 use ice_table_mod, only: icetable_equilibrium, icetable_dynamic 31 31 32 character(len=20), parameter :: modname ='conf_pem' 33 integer :: ierr 34 integer :: year_earth_bp_ini ! Initial year (in Earth years) of the simulation of the PEM defined in run.def 32 implicit none 33 34 integer, intent(out) :: i_myear, n_myears ! Current simulated Martian year and maximum number of Martian years to be simulated 35 36 character(20), parameter :: modname ='conf_pem' 37 integer :: ierr 38 integer :: year_earth_bp_ini ! Initial year (in Earth years) of the simulation of the PEM defined in run.def 35 39 36 40 !PEM parameters … … 48 52 49 53 ! #---------- Orbital parameters 50 evol_orbit_pem=.false.51 54 evol_orbit_pem = .false. 55 call getin('evol_orbit_pem',evol_orbit_pem) 52 56 53 54 55 57 year_bp_ini = 0. 58 call getin('year_earth_bp_ini',year_earth_bp_ini) 59 year_bp_ini = year_earth_bp_ini/convert_years 56 60 57 58 59 61 var_obl = .true. 62 call getin('var_obl',var_obl) 63 write(*,*) 'Does obliquity vary ?',var_obl 60 64 61 62 63 65 var_ecc = .true. 66 call getin('var_ecc',var_ecc) 67 write(*,*) 'Does excentricity vary ?',var_ecc 64 68 65 66 67 69 var_lsp = .true. 70 call getin('var_lsp',var_lsp) 71 write(*,*) 'Does Ls peri vary ?',var_lsp 68 72 69 73 ! #---------- Stopping criteria parameters 70 Max_iter_pem=10000000071 call getin('Max_iter_pem',Max_iter_pem)74 Max_iter_pem = 100000000 75 call getin('Max_iter_pem',Max_iter_pem) 72 76 73 water_ice_criterion=0.274 call getin('water_ice_criterion',water_ice_criterion)77 water_ice_criterion = 0.2 78 call getin('water_ice_criterion',water_ice_criterion) 75 79 76 co2_ice_criterion=0.277 call getin('co2_ice_criterion',co2_ice_criterion)80 co2_ice_criterion = 0.2 81 call getin('co2_ice_criterion',co2_ice_criterion) 78 82 79 80 83 ps_criterion = 0.15 84 call getin('ps_criterion',ps_criterion) 81 85 82 dt_pem=183 86 dt_pem = 1 87 call getin('dt_pem', dt_pem) 84 88 85 89 ! #---------- Subsurface parameters 86 soil_pem=.true.87 call getin('soil_pem',soil_pem)90 soil_pem = .true. 91 call getin('soil_pem',soil_pem) 88 92 89 90 93 adsorption_pem = .true. 94 call getin('adsorption_pem',adsorption_pem) 91 95 92 93 call getin('co2glaciersflow',co2glaciersflow)96 co2glaciersflow = .true. 97 call getin('co2glaciersflow',co2glaciersflow) 94 98 95 96 call getin('h2oglaciersflow',h2oglaciersflow)99 h2oglaciersflow = .true. 100 call getin('h2oglaciersflow',h2oglaciersflow) 97 101 98 99 100 102 reg_thprop_dependp = .false. 103 call getin('reg_thprop_dependp',reg_thprop_dependp) 104 write(*,*) 'Thermal properties of the regolith vary with pressure ?', reg_thprop_dependp 101 105 102 106 ! #---------- Layering parameters 103 fluxgeo = 0. 104 call getin('fluxgeo',fluxgeo) 105 write(*,*) 'Flux Geothermal is set to',fluxgeo 106 107 depth_breccia = 10. 108 call getin('depth_breccia',depth_breccia) 109 write(*,*) 'Depth of breccia is set to',depth_breccia 107 fluxgeo = 0. 108 call getin('fluxgeo',fluxgeo) 109 write(*,*) 'Flux Geothermal is set to',fluxgeo 110 110 111 depth_bedrock = 1000.112 call getin('depth_bedrock',depth_bedrock)113 write(*,*) 'Depth of bedrock is set to',depth_bedrock 111 depth_breccia = 10. 112 call getin('depth_breccia',depth_breccia) 113 write(*,*) 'Depth of breccia is set to',depth_breccia 114 114 115 icetable_equilibrium = .true.116 call getin('icetable_equilibrium',icetable_equilibrium)117 write(*,*) 'Is the ice table computed at equilibrium?', icetable_equilibrium 115 depth_bedrock = 1000. 116 call getin('depth_bedrock',depth_bedrock) 117 write(*,*) 'Depth of bedrock is set to',depth_bedrock 118 118 119 icetable_dynamic = .false. 120 call getin('icetable_dynamic',icetable_dynamic) 121 write(*,*) 'Is the ice table computed with the dynamic method?', icetable_dynamic 122 if ((.not.soil_pem).and.((icetable_equilibrium).or.(icetable_dynamic))) then 123 write(*,*) 'Ice table must be used when soil_pem = T' 124 call abort_physic(modname,"Ice table must be used when soil_pem = T",1) 125 endif 119 icetable_equilibrium = .true. 120 call getin('icetable_equilibrium',icetable_equilibrium) 121 write(*,*) 'Is the ice table computed at equilibrium?', icetable_equilibrium 126 122 127 if ((.not.soil_pem).and.adsorption_pem) then 128 write(*,*) 'Adsorption must be used when soil_pem = T' 129 call abort_physic(modname,"Adsorption must be used when soil_pem = T",1) 130 endif 131 132 if ((.not.soil_pem).and.(fluxgeo.gt.0.)) then 133 write(*,*) 'Soil is not activated but Flux Geo > 0.' 134 call abort_physic(modname,"Soil is not activated but Flux Geo > 0.",1) 135 endif 136 137 if ((.not.soil_pem).and.reg_thprop_dependp) then 138 write(*,*) 'Regolith properties vary with Ps only when soil is set to true' 139 call abort_physic(modname,'Regolith properties vary with Ps only when soil is set to true',1) 140 endif 123 icetable_dynamic = .false. 124 call getin('icetable_dynamic',icetable_dynamic) 125 write(*,*) 'Is the ice table computed with the dynamic method?', icetable_dynamic 126 if ((.not. soil_pem) .and. ((icetable_equilibrium) .or. (icetable_dynamic))) then 127 write(*,*) 'Ice table must be used when soil_pem = T' 128 call abort_physic(modname,"Ice table must be used when soil_pem = T",1) 129 endif 141 130 142 if (evol_orbit_pem .and. year_bp_ini == 0.) then 143 write(*,*) 'You want to follow the file obl_ecc_lsp.asc for changing orb parameters,' 144 write(*,*) 'but you did not specify from which year to start.' 145 call abort_physic(modname,"evol_orbit_pem=.true. but year_bp_ini=0",1) 146 endif 131 if ((.not. soil_pem) .and. adsorption_pem) then 132 write(*,*) 'Adsorption must be used when soil_pem = T' 133 call abort_physic(modname,"Adsorption must be used when soil_pem = T",1) 134 endif 147 135 148 water_reservoir_nom = 1e4 149 call getin('water_reservoir_nom',water_reservoir_nom) 136 if ((.not. soil_pem) .and. (fluxgeo > 0.)) then 137 write(*,*) 'Soil is not activated but Flux Geo > 0.' 138 call abort_physic(modname,"Soil is not activated but Flux Geo > 0.",1) 139 endif 150 140 151 END SUBROUTINE conf_pem 141 if ((.not. soil_pem) .and. reg_thprop_dependp) then 142 write(*,*) 'Regolith properties vary with Ps only when soil is set to true' 143 call abort_physic(modname,'Regolith properties vary with Ps only when soil is set to true',1) 144 endif 145 146 if (evol_orbit_pem .and. year_bp_ini == 0.) then 147 write(*,*) 'You want to follow the file obl_ecc_lsp.asc for changing orb parameters,' 148 write(*,*) 'but you did not specify from which year to start.' 149 call abort_physic(modname,"evol_orbit_pem=.true. but year_bp_ini=0",1) 150 endif 151 152 water_reservoir_nom = 1.e4 153 call getin('water_reservoir_nom',water_reservoir_nom) 154 155 END SUBROUTINE conf_pem 152 156 153 157 END MODULE conf_pem_mod -
trunk/LMDZ.COMMON/libf/evolution/constants_marspem_mod.F90
r2998 r3076 1 1 MODULE constants_marspem_mod 2 2 3 implicit none 3 4 4 IMPLICIT NONE5 5 ! Duration of a year and day 6 INTEGER,PARAMETER :: sols_per_my =669! Number of Sols per year7 REAL, PARAMETER :: sec_per_sol=88775.! Duration of a sol, in seconds6 integer, parameter :: sols_per_my = 669 ! Number of Sols per year 7 real, parameter :: sec_per_sol = 88775. ! Duration of a sol, in seconds 8 8 9 9 ! Molecular masses for CO2,H2O and non condensible gaz, following Franz et al. 2017 10 REAL,PARAMETER :: m_co2 = 44.01E-3! CO2 molecular mass (kg/mol)11 REAL,PARAMETER :: m_noco2 = 33.37E-3 ! Non condensible mol mass (kg/mol)12 REAL,PARAMETER :: m_h2o = 18.01528E-3! Molecular weight of h2o (kg/mol)10 real, parameter :: m_co2 = 44.01e-3 ! CO2 molecular mass (kg/mol) 11 real, parameter :: m_noco2 = 33.37e-3 ! Non condensible mol mass (kg/mol) 12 real, parameter :: m_h2o = 18.01528e-3 ! Molecular weight of h2o (kg/mol) 13 13 14 14 ! Coefficient for Clapeyron law for CO2 condensation temperature (Tco2 = beta/(alpha-log(vmr)),following James et al. 1992 15 REAL,PARAMETER :: alpha_clap_co2 = 23.3494 !Uniteless,James et al. 199216 REAL,PARAMETER :: beta_clap_co2 = 3182.48 !Kelvin, James et al. 199215 real, parameter :: alpha_clap_co2 = 23.3494 ! Uniteless, James et al. 1992 16 real, parameter :: beta_clap_co2 = 3182.48 ! Kelvin, James et al. 1992 17 17 18 18 ! Coefficient for Clapeyron law for psat (psat = exp(beta/Th2o+alpha)),following Murphy and Koop 2005 19 REAL,PARAMETER :: alpha_clap_h2o = 28.9074! Uniteless, Murphy and Koop 200520 REAL,PARAMETER :: beta_clap_h2o = -6143.7! Kelvin, Murphy and Koop 200519 real, parameter :: alpha_clap_h2o = 28.9074 ! Uniteless, Murphy and Koop 2005 20 real, parameter :: beta_clap_h2o = -6143.7 ! Kelvin, Murphy and Koop 2005 21 21 22 22 ! Density of the regolith (Zent et al., 1995, Buhler and Piqueux 2021) 23 REAL,PARAMETER :: rho_regolith = 2000.! kg/m^323 real, parameter :: rho_regolith = 2000. ! kg/m^3 24 24 25 25 ! Average Thermal inertia of the surface, breccia, bedrock, following Mellon et al., 2000., Wood et al., 2008 26 REAL,PARAMETER :: TI_regolith_avg = 250.! Averaged of the observed thermal inertia for regolith following Mellon et al., 2000[SI]27 REAL,PARAMETER :: TI_breccia = 750.! Thermal inertia of Breccia following Wood 2009 [SI]28 REAL,PARAMETER :: TI_bedrock = 2300.! Thermal inertia of Bedrock following Wood 2009 [SI]26 real, parameter :: TI_regolith_avg = 250. ! Averaged of the observed thermal inertia for regolith following Mellon et al., 2000[SI] 27 real, parameter :: TI_breccia = 750. ! Thermal inertia of Breccia following Wood 2009 [SI] 28 real, parameter :: TI_bedrock = 2300. ! Thermal inertia of Bedrock following Wood 2009 [SI] 29 29 30 30 ! Porosity of the soil 31 REAL,PARAMETER :: porosity = 0.4! porosity of the martian soil, correspond to the value for a random loose packing of monodiperse sphere (Scott, 1960)31 real, parameter :: porosity = 0.4 ! porosity of the martian soil, correspond to the value for a random loose packing of monodiperse sphere (Scott, 1960) 32 32 33 33 ! Stefan Boltzmann constant 34 REAL,PARAMETER :: sigmaB=5.678E-834 real, parameter :: sigmaB = 5.678e-8 35 35 36 36 ! Latent heat of CO2 37 REAL,PARAMETER :: Lco2 = 5.71E5! Pilorget and Forget 201637 real, parameter :: Lco2 = 5.71e5 ! Pilorget and Forget 2016 38 38 39 39 ! Conversion H2O/CO2 frost to perenial frost and vice versa 40 REAL,PARAMETER:: threshold_water_frost2perenial = 1000. !~ 1m41 REAL,PARAMETER:: threshold_co2_frost2perenial = 3200. !~ 2m40 real, parameter :: threshold_water_frost2perenial = 1000. !~ 1m 41 real, parameter :: threshold_co2_frost2perenial = 3200. !~ 2m 42 42 43 END MODULE constants_marspem_mod 43 44 44 45 END MODULE constants_marspem_mod46 -
trunk/LMDZ.COMMON/libf/evolution/glaciers_mod.F90
r3002 r3076 26 26 !!! 27 27 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 28 29 28 30 29 IMPLICIT NONE … … 105 104 subroutine compute_hmaxglaciers(ngrid,nslope,iflat,def_slope_mean,Tice,name_ice,hmax) 106 105 107 USE comconst_mod, ONLY: pi,g 106 use comconst_mod, only: pi,g 107 use abort_pem_mod, only: abort_pem 108 108 109 109 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! … … 181 181 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 182 182 183 USE comconst_mod, ONLY: pi 183 use comconst_mod, only: pi 184 use abort_pem_mod, only: abort_pem 184 185 185 186 -
trunk/LMDZ.COMMON/libf/evolution/info_run_PEM_mod.F90
r3075 r3076 1 MODULE info_run_PEM_mod 2 3 implicit none 4 5 !======================================================================= 6 contains 7 !======================================================================= 8 1 9 SUBROUTINE info_run_PEM(year_iter,criterion_stop,i_myear,n_myear) 2 10 … … 9 17 !======================================================================= 10 18 11 19 use time_evol_mod, only: convert_years 12 20 13 IMPLICIT NONE 21 implicit none 14 22 15 integer, intent(in) :: year_iter, criterion_stop ! # of year and reason to stop 16 integer, intent(in) :: i_myear, n_myear ! Current simulated Martian year and maximum number of Martian years to be simulated 23 !----- Arguments 24 integer, intent(in) :: year_iter, criterion_stop ! # of year and reason to stop 25 integer, intent(in) :: i_myear, n_myear ! Current simulated Martian year and maximum number of Martian years to be simulated 17 26 18 logical :: ok 27 !----- Local variables 28 logical :: ok 19 29 30 !----- Code 20 31 inquire(file = 'info_run_PEM.txt', exist = ok) 21 32 if (ok) then … … 32 43 33 44 END SUBROUTINE info_run_PEM 45 46 END MODULE info_run_PEM_mod -
trunk/LMDZ.COMMON/libf/evolution/interpolate_TIPEM_TIGCM_mod.F90
r3075 r3076 1 subroutine interpolate_TIPEM_TIGCM(ngrid,nslope,nsoil_PEM,nsoil_GCM,TI_PEM,TI_GCM) 1 MODULE interpolate_TIPEM_TIGCM_mod 2 3 implicit none 4 5 !======================================================================= 6 contains 7 !======================================================================= 8 9 SUBROUTINE interpolate_TIPEM_TIGCM(ngrid,nslope,nsoil_PEM,nsoil_GCM,TI_PEM,TI_GCM) 2 10 3 11 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 4 12 !!! 5 13 !!! Purpose: Transfer the thermal inertia from the PEM vertical grid to the GCM vertical grid 6 !!! 7 !!! 14 !!! 15 !!! 8 16 !!! Author: LL 9 17 !!! 10 18 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 11 19 12 13 implicit none 14 20 implicit none 15 21 16 22 !====================================================================== … … 18 24 ! --------- 19 25 ! inputs: 20 integer,intent(in) :: ngrid ! # of horizontal grid points 21 integer,intent(in) :: nslope ! # of subslope wihtin the mesh 22 integer,intent(in) :: nsoil_PEM ! # of soil layers in the PEM 23 integer,intent(in) :: nsoil_GCM ! # of soil layers in the GCM 24 real,intent(in) :: TI_PEM(ngrid,nsoil_PEM,nslope) ! Thermal inertia in the PEM vertical grid [J/m^2/K/s^{1/2}] 25 real,intent(inout) :: TI_GCM(ngrid,nsoil_GCM,nslope) ! Thermal inertia in the GCM vertical grid [J/m^2/K/s^{1/2}] 26 integer, intent(in) :: ngrid ! # of horizontal grid points 27 integer, intent(in) :: nslope ! # of subslope wihtin the mesh 28 integer, intent(in) :: nsoil_PEM ! # of soil layers in the PEM 29 integer, intent(in) :: nsoil_GCM ! # of soil layers in the GCM 30 real, dimension(ngrid,nsoil_PEM,nslope), intent(in) :: TI_PEM ! Thermal inertia in the PEM vertical grid [J/m^2/K/s^{1/2}] 26 31 27 !local variable 28 integer :: ig,islope,iloop ! loop variables 29 do ig = 1,ngrid 30 do islope = 1,nslope 31 do iloop = 1,nsoil_GCM 32 TI_GCM(ig,iloop,islope) = TI_PEM(ig,iloop,islope) 33 enddo 34 enddo 35 enddo 32 real, dimension(ngrid,nsoil_GCM,nslope), intent(inout) :: TI_GCM ! Thermal inertia in the GCM vertical grid [J/m^2/K/s^{1/2}] 36 33 34 !----- Code 35 TI_GCM(:,:,:) = TI_PEM(:,:nsoil_GCM,:) 37 36 38 end subroutine interpolate_TIPEM_TIGCM 37 END SUBROUTINE interpolate_TIPEM_TIGCM 38 39 END MODULE interpolate_TIPEM_TIGCM_mod -
trunk/LMDZ.COMMON/libf/evolution/lask_param_mod.F90
r3039 r3076 1 module lask_param_mod 1 MODULE lask_param_mod 2 2 3 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3 4 !!! 4 5 !!! Purpose: Define parameters from Laskar et al., 2004 evolution 5 !!! 6 !!! 6 7 !!! Author: RV, JBC 7 8 !!! … … 10 11 implicit none 11 12 12 real,save,allocatable :: yearlask(:)! year before present from Laskar et al. Tab13 real,save,allocatable :: obllask(:)! obliquity [deg]14 real,save,allocatable :: ecclask(:)! excentricity [deg]15 real,save,allocatable :: lsplask(:)! ls perihelie [deg]16 integer, save :: last_ilask! Index of the line in the file year_obl_lask.asc corresponding to the closest lower year to the current year13 real, dimension(:), allocatable, save :: yearlask ! year before present from Laskar et al. Tab 14 real, dimension(:), allocatable, save :: obllask ! obliquity [deg] 15 real, dimension(:), allocatable, save :: ecclask ! excentricity [deg] 16 real, dimension(:), allocatable, save :: lsplask ! ls perihelie [deg] 17 integer, save :: last_ilask ! Index of the line in the file year_obl_lask.asc corresponding to the closest lower year to the current year 17 18 19 !======================================================================= 18 20 contains 21 !======================================================================= 19 22 20 subroutine ini_lask_param_mod 21 22 implicit none 23 SUBROUTINE ini_lask_param_mod 23 24 24 integer :: nlask ! number of lines in Laskar files 25 integer :: ierr 25 implicit none 26 26 27 nlask = 0 28 open(1,file = 'obl_ecc_lsp.asc') 29 do 30 read(1,*,iostat = ierr) 31 if (ierr /= 0) exit 32 nlask = nlask + 1 33 enddo 34 close(1) 35 allocate(yearlask(nlask)) 36 allocate(obllask(nlask)) 37 allocate(ecclask(nlask)) 38 allocate(lsplask(nlask)) 39 40 end subroutine ini_lask_param_mod 27 integer :: nlask ! number of lines in Laskar files 28 integer :: ierr 41 29 30 nlask = 0 31 open(1,file = 'obl_ecc_lsp.asc') 32 do 33 read(1,*,iostat = ierr) 34 if (ierr /= 0) exit 35 nlask = nlask + 1 36 enddo 37 close(1) 38 allocate(yearlask(nlask),obllask(nlask),ecclask(nlask),lsplask(nlask)) 42 39 43 subroutine end_lask_param_mod40 END SUBROUTINE ini_lask_param_mod 44 41 45 implicit none 42 !======================================================================= 46 43 47 if (allocated(yearlask)) deallocate(yearlask) 48 if (allocated(obllask)) deallocate(obllask) 49 if (allocated(ecclask)) deallocate(ecclask) 50 if (allocated(lsplask)) deallocate(lsplask) 44 SUBROUTINE end_lask_param_mod 51 45 52 end subroutine end_lask_param_mod 53 54 end module lask_param_mod 46 implicit none 47 48 if (allocated(yearlask)) deallocate(yearlask) 49 if (allocated(obllask)) deallocate(obllask) 50 if (allocated(ecclask)) deallocate(ecclask) 51 if (allocated(lsplask)) deallocate(lsplask) 52 53 END SUBROUTINE end_lask_param_mod 54 55 END MODULE lask_param_mod -
trunk/LMDZ.COMMON/libf/evolution/nb_time_step_GCM_mod.F90
r3075 r3076 1 ! 2 ! $Id $ 3 ! 1 MODULE nb_time_step_GCM_mod 2 3 use netcdf, only: nf90_open, NF90_NOWRITE, nf90_noerr, nf90_strerror, & 4 nf90_get_var, nf90_inq_varid, nf90_inq_dimid, & 5 nf90_inquire_dimension, nf90_close 6 7 implicit none 8 9 character(256) :: msg, var, modname 10 11 !======================================================================= 12 contains 13 !======================================================================= 14 4 15 SUBROUTINE nb_time_step_GCM(fichnom,timelen) 5 16 6 use netcdf, only: nf90_open,NF90_NOWRITE,nf90_noerr,nf90_strerror, & 7 nf90_get_var, nf90_inq_varid, nf90_inq_dimid, & 8 nf90_inquire_dimension,nf90_close 9 10 IMPLICIT NONE 17 implicit none 11 18 12 19 !======================================================================= … … 17 24 !======================================================================= 18 25 19 26 include "dimensions.h" 20 27 21 !======================================================================= ========28 !======================================================================= 22 29 ! Arguments: 23 CHARACTER(LEN=*), INTENT(IN) :: fichnom !--- FILE NAME 24 !=============================================================================== 25 ! Local Variables 26 CHARACTER(LEN=256) :: msg, var, modname 27 INTEGER :: iq, fID, vID, idecal 28 INTEGER :: ierr 29 30 INTEGER :: timelen ! number of times stored in the file 30 character(len = *), intent(in) :: fichnom !--- FILE NAME 31 !======================================================================= 32 ! Local Variables 33 integer :: iq, fID, vID, idecal, ierr 34 integer :: timelen ! number of times stored in the file 31 35 !----------------------------------------------------------------------- 32 modname="nb_time_step_GCM"36 modname = "nb_time_step_GCM" 33 37 34 38 ! Open initial state NetCDF file 35 var=fichnom36 CALL err(NF90_OPEN(var,NF90_NOWRITE,fID),"open",var)39 var = fichnom 40 call error_msg(NF90_OPEN(var,NF90_NOWRITE,fID),"open",var) 37 41 38 39 IF (ierr .NE. nf90_noerr) THEN 40 41 42 43 IF (ierr .NE. nf90_noerr) THEN44 45 46 47 IF (ierr .NE. nf90_noerr) THEN42 ierr = nf90_inq_varid (fID, "temps", vID) 43 if (ierr /= nf90_noerr) then 44 write(*,*)"read_data_GCM: Le champ <temps> est absent" 45 write(*,*)"read_data_GCM: J essaie <time_counter>" 46 ierr = nf90_inq_varid (fID, "time_counter", vID) 47 if (ierr /= nf90_noerr) then 48 write(*,*)"read_data_GCM: Le champ <time_counter> est absent" 49 write(*,*)"read_data_GCM: J essaie <Time>" 50 ierr = nf90_inq_varid (fID, "Time", vID) 51 if (ierr /= nf90_noerr) then 48 52 write(*,*)"read_data_GCM: Le champ <Time> est absent" 49 53 write(*,*)trim(nf90_strerror(ierr)) 50 CALL ABORT_gcm("nb_time_step_GCM", "", 1)51 ENDIF52 53 54 ierr = nf90_inquire_dimension(fID,vID,len=timelen)55 ELSE54 call abort_gcm("nb_time_step_GCM", "", 1) 55 endif 56 ! Get the length of the "Time" dimension 57 ierr = nf90_inq_dimid(fID,"Time",vID) 58 ierr = nf90_inquire_dimension(fID,vID,len = timelen) 59 else 56 60 ! Get the length of the "time_counter" dimension 57 61 ierr = nf90_inq_dimid(fID,"time_counter",vID) 58 ierr = nf90_inquire_dimension(fID,vID,len =timelen)59 ENDIF60 ELSE 61 62 63 ierr = nf90_inquire_dimension(fID,vID,len=timelen)64 ENDIF 62 ierr = nf90_inquire_dimension(fID,vID,len = timelen) 63 endif 64 else 65 ! Get the length of the "temps" dimension 66 ierr = nf90_inq_dimid(fID,"temps",vID) 67 ierr = nf90_inquire_dimension(fID,vID,len = timelen) 68 endif 65 69 66 CALL err(NF90_CLOSE(fID),"close",fichnom)70 call error_msg(NF90_CLOSE(fID),"close",fichnom) 67 71 68 write(*,*) "The number of timestep of the PCM run data=", timelen 69 70 CONTAINS 71 72 SUBROUTINE err(ierr,typ,nam) 73 INTEGER, INTENT(IN) :: ierr !--- NetCDF ERROR CODE 74 CHARACTER(LEN=*), INTENT(IN) :: typ !--- TYPE OF OPERATION 75 CHARACTER(LEN=*), INTENT(IN) :: nam !--- FIELD/FILE NAME 76 IF(ierr==NF90_NoERR) RETURN 77 SELECT CASE(typ) 78 CASE('inq'); msg="Field <"//TRIM(nam)//"> is missing" 79 CASE('get'); msg="Reading failed for <"//TRIM(nam)//">" 80 CASE('open'); msg="File opening failed for <"//TRIM(nam)//">" 81 CASE('close'); msg="File closing failed for <"//TRIM(nam)//">" 82 END SELECT 83 CALL ABORT_gcm(TRIM(modname),TRIM(msg),ierr) 84 END SUBROUTINE err 72 write(*,*) "The number of timestep of the PCM run data=", timelen 85 73 86 74 END SUBROUTINE nb_time_step_GCM 75 76 !======================================================================= 77 78 SUBROUTINE error_msg(ierr,typ,nam) 79 80 implicit none 81 82 integer, intent(in) :: ierr !--- NetCDF ERROR CODE 83 character(len = *), intent(in) :: typ !--- TYPE OF OPERATION 84 character(len = *), intent(in) :: nam !--- FIELD/FILE NAME 85 86 if (ierr == nf90_noerr) return 87 select case(typ) 88 case('inq'); msg = "Field <"//trim(nam)//"> is missing" 89 case('get'); msg = "Reading failed for <"//trim(nam)//">" 90 case('open'); msg = "File opening failed for <"//trim(nam)//">" 91 case('close'); msg = "File closing failed for <"//trim(nam)//">" 92 case default 93 write(*,*) 'There is no message for this error.' 94 error stop 95 end select 96 call abort_gcm(trim(modname),trim(msg),ierr) 97 98 END SUBROUTINE error_msg 99 100 END MODULE nb_time_step_GCM_mod -
trunk/LMDZ.COMMON/libf/evolution/orbit_param_criterion_mod.F90
r3069 r3076 3 3 !======================================================================= 4 4 ! 5 ! Purpose: Compute the maximum number of iteration for PEM based on the 5 ! Purpose: Compute the maximum number of iteration for PEM based on the 6 6 ! stopping criterion given by the orbital parameters 7 7 ! … … 9 9 !======================================================================= 10 10 11 IMPLICIT NONE 12 13 CONTAINS 11 implicit none 12 13 !======================================================================= 14 contains 15 !======================================================================= 14 16 15 17 SUBROUTINE orbit_param_criterion(i_myear,year_iter_max) … … 26 28 use planete_mod, only: e_elips, obliquit, lsperi 27 29 #endif 28 29 30 31 32 IMPLICIT NONE 30 use time_evol_mod, only: year_bp_ini, var_obl, var_ecc, var_lsp, convert_years 31 use comconst_mod, only: pi 32 use lask_param_mod, only: yearlask, obllask, ecclask, lsplask, ini_lask_param_mod, last_ilask 33 34 implicit none 33 35 34 36 !-------------------------------------------------------- 35 37 ! Input Variables 36 38 !-------------------------------------------------------- 37 39 integer, intent(in) :: i_myear ! Martian year of the simulation 38 40 39 41 !-------------------------------------------------------- 40 42 ! Output Variables 41 43 !-------------------------------------------------------- 42 43 44 !-------------------------------------------------------- 45 ! Local variables 46 !-------------------------------------------------------- 47 48 49 50 51 52 53 54 55 56 44 integer, intent(out) :: year_iter_max ! Maximum number of iteration of the PEM before orb changes too much 45 46 !-------------------------------------------------------- 47 ! Local variables 48 !-------------------------------------------------------- 49 integer :: Year ! Year of the simulation 50 real :: Lsp ! Ls perihelion 51 real :: max_change_obl, max_change_ecc, max_change_lsp ! Maximum admissible change 52 real :: max_obl, max_ecc, max_lsp ! Maximum value of orbit param given the admissible change 53 real :: min_obl, min_ecc, min_lsp ! Minimum value of orbit param given the admissible change 54 integer :: max_obl_iter, max_ecc_iter, max_lsp_iter ! Maximum year iteration before reaching an inadmissible value of orbit param 55 integer :: ilask, iylask ! Loop variables 56 real :: xa, xb, ya, yb ! Variables for interpolation 57 logical :: found_obl, found_ecc, found_lsp ! Flag variables for orbital parameters 58 logical :: crossed_modulo_d, crossed_modulo_i ! Flag variables for modulo of Lsp 57 59 58 60 ! ********************************************************************** … … 84 86 endif 85 87 86 ! Constant max change case 88 ! Constant max change case 87 89 max_change_obl = 0.6 88 90 max_change_ecc = 2.8e-3 … … 106 108 write(*,*) 'Maximum Lsp accepted =', max_lsp 107 109 write(*,*) 'Minimum Lsp accepted =', min_lsp 108 ! End Constant max change case 110 ! End Constant max change case 109 111 110 112 ! If we do not want some orb parameter to change, they should not be a stopping criterion, … … 175 177 endif 176 178 else 177 if (crossed_modulo_d) then ! If decreasing Lsp "crossed" the modulo but min_lsp has not been met yet 179 if (crossed_modulo_d) then ! If decreasing Lsp "crossed" the modulo but min_lsp has not been met yet 178 180 ya = ya - 360. 179 181 yb = yb - 360. … … 208 210 END SUBROUTINE orbit_param_criterion 209 211 210 !*********************************************************************** *********212 !*********************************************************************** 211 213 212 214 END MODULE orbit_param_criterion_mod -
trunk/LMDZ.COMMON/libf/evolution/pem.F90
r3072 r3076 27 27 PROGRAM pem 28 28 29 use phyetat0_mod, only: phyetat030 use phyredem, only: physdem0, physdem131 use netcdf, only: nf90_open, NF90_NOWRITE, nf90_get_var, nf90_inq_varid, nf90_close32 use turb_mod, only: q2, wstar33 use comslope_mod, only: nslope, def_slope, def_slope_mean, subslope_dist, iflat, major_slope, ini_comslope_h34 use logic_mod, only: iflag_phys35 use mod_const_mpi, only: COMM_LMDZ29 use phyetat0_mod, only: phyetat0 30 use phyredem, only: physdem0, physdem1 31 use netcdf, only: nf90_open, NF90_NOWRITE, nf90_get_var, nf90_inq_varid, nf90_close 32 use turb_mod, only: q2, wstar 33 use comslope_mod, only: nslope, def_slope, def_slope_mean, subslope_dist, iflat, major_slope, ini_comslope_h 34 use logic_mod, only: iflag_phys 35 use mod_const_mpi, only: COMM_LMDZ 36 36 use infotrac 37 use geometry_mod, only: latitude_deg 38 use conf_pem_mod, only: conf_pem 39 use pemredem, only: pemdem0, pemdem1 40 use glaciers_mod, only: co2glaciers_evol, h2oglaciers_evol, co2glaciersflow, h2oglaciersflow 41 use criterion_pem_stop_mod, only: criterion_waterice_stop, criterion_co2_stop 42 use constants_marspem_mod, only: alpha_clap_co2, beta_clap_co2, alpha_clap_h2o, beta_clap_h2o, m_co2, & 43 m_noco2, threshold_water_frost2perenial, threshold_co2_frost2perenial 44 use evol_co2_ice_s_mod, only: evol_co2_ice_s 45 use evol_h2o_ice_s_mod, only: evol_h2o_ice_s 46 use comsoil_h_PEM, only: soil_pem, ini_comsoil_h_PEM, end_comsoil_h_PEM, nsoilmx_PEM, & 47 TI_PEM, inertiedat_PEM, & ! soil thermal inertia 48 tsoil_PEM, mlayer_PEM, layer_PEM, & ! Soil temp, number of subsurface layers, soil mid layer depths 49 fluxgeo, & ! Geothermal flux for the PEM and GCM 50 water_reservoir ! Water ressources 51 use adsorption_mod, only: regolith_adsorption, adsorption_pem, & ! Bool to check if adsorption, main subroutine 52 ini_adsorption_h_PEM, end_adsorption_h_PEM, & ! Allocate arrays 53 co2_adsorbded_phys, h2o_adsorbded_phys ! Mass of co2 and h2O adsorbded 54 use time_evol_mod, only: dt_pem, evol_orbit_pem, Max_iter_pem, convert_years, year_bp_ini 55 use orbit_param_criterion_mod, only: orbit_param_criterion 56 use recomp_orb_param_mod, only: recomp_orb_param 57 use ice_table_mod, only: porefillingice_depth, porefillingice_thickness, end_ice_table_porefilling, & 58 ini_ice_table_porefilling, computeice_table_equilibrium,compute_massh2o_exchange_ssi 59 use soil_thermalproperties_mod, only: update_soil_thermalproperties 60 use time_phylmdz_mod, only: daysec, dtphys, day_end 37 use geometry_mod, only: latitude_deg 38 use conf_pem_mod, only: conf_pem 39 use pemredem, only: pemdem0, pemdem1 40 use glaciers_mod, only: co2glaciers_evol, h2oglaciers_evol, co2glaciersflow, h2oglaciersflow 41 use criterion_pem_stop_mod, only: criterion_waterice_stop, criterion_co2_stop 42 use constants_marspem_mod, only: alpha_clap_co2, beta_clap_co2, alpha_clap_h2o, beta_clap_h2o, m_co2, & 43 m_noco2, threshold_water_frost2perenial, threshold_co2_frost2perenial 44 use evol_co2_ice_s_mod, only: evol_co2_ice_s 45 use evol_h2o_ice_s_mod, only: evol_h2o_ice_s 46 use comsoil_h_PEM, only: soil_pem, ini_comsoil_h_PEM, end_comsoil_h_PEM, nsoilmx_PEM, & 47 TI_PEM, inertiedat_PEM, & ! soil thermal inertia 48 tsoil_PEM, mlayer_PEM, layer_PEM, & ! Soil temp, number of subsurface layers, soil mid layer depths 49 fluxgeo, & ! Geothermal flux for the PEM and GCM 50 water_reservoir ! Water ressources 51 use adsorption_mod, only: regolith_adsorption, adsorption_pem, & ! Bool to check if adsorption, main subroutine 52 ini_adsorption_h_PEM, end_adsorption_h_PEM, & ! Allocate arrays 53 co2_adsorbded_phys, h2o_adsorbded_phys ! Mass of co2 and h2O adsorbded 54 use time_evol_mod, only: dt_pem, evol_orbit_pem, Max_iter_pem, convert_years, year_bp_ini 55 use orbit_param_criterion_mod, only: orbit_param_criterion 56 use recomp_orb_param_mod, only: recomp_orb_param 57 use ice_table_mod, only: porefillingice_depth, porefillingice_thickness, end_ice_table_porefilling, & 58 ini_ice_table_porefilling, computeice_table_equilibrium,compute_massh2o_exchange_ssi 59 use soil_thermalproperties_mod, only: update_soil_thermalproperties 60 use time_phylmdz_mod, only: daysec, dtphys, day_end 61 use abort_pem_mod, only: abort_pem 62 use soil_settings_PEM_mod, only: soil_settings_PEM 63 use compute_tendencies_slope_mod, only: compute_tendencies_slope 64 use info_run_PEM_mod, only: info_run_PEM 65 use interpolate_TIPEM_TIGCM_mod, only: interpolate_TIPEM_TIGCM 66 use nb_time_step_GCM_mod, only: nb_time_step_GCM 67 use pemetat0_mod, only: pemetat0 68 use read_data_GCM_mod, only: read_data_GCM 69 use recomp_tend_co2_slope_mod, only: recomp_tend_co2_slope 70 use soil_pem_compute_mod, only: soil_pem_compute 61 71 62 72 #ifndef CPP_STD … … 85 95 86 96 #ifndef CPP_1D 87 use iniphysiq_mod, only: iniphysiq88 use control_mod, only: iphysiq, day_step, nsplit_phys89 use comconst_mod, only: rad, g, cpp, pi97 use iniphysiq_mod, only: iniphysiq 98 use control_mod, only: iphysiq, day_step, nsplit_phys 99 use comconst_mod, only: rad, g, cpp, pi 90 100 #else 91 use time_phylmdz_mod, only: iphysiq, day_step 92 use comcstfi_h, only: pi, rad, g, cpp 93 #endif 94 95 #ifdef CPP_1D 101 use time_phylmdz_mod, only: iphysiq, day_step 102 use comcstfi_h, only: pi, rad, g, cpp 96 103 use regular_lonlat_mod, only: init_regular_lonlat 97 104 use physics_distribution_mod, only: init_physics_distribution … … 99 106 use init_testphys1d_mod, only: init_testphys1d 100 107 use comvert_mod, only: ap, bp 108 use writerestart1D_mod, only: writerestart1D 101 109 #endif 102 110 103 IMPLICIT NONE 111 implicit none 104 112 105 113 include "dimensions.h" … … 858 866 Tsoil_locslope(:,:) = tsoil_phys_PEM_timeseries(:,:,islope,t) 859 867 Tsurf_locslope(:) = tsurf_GCM_timeseries(:,islope,t) 860 call soil_pem_ routine(ngrid,nsoilmx_PEM,.true.,TI_locslope,timestep/timelen,Tsurf_locslope,Tsoil_locslope)861 call soil_pem_ routine(ngrid,nsoilmx_PEM,.false.,TI_locslope,timestep/timelen,Tsurf_locslope,Tsoil_locslope)868 call soil_pem_compute(ngrid,nsoilmx_PEM,.true.,TI_locslope,timestep/timelen,Tsurf_locslope,Tsoil_locslope) 869 call soil_pem_compute(ngrid,nsoilmx_PEM,.false.,TI_locslope,timestep/timelen,Tsurf_locslope,Tsoil_locslope) 862 870 tsoil_phys_PEM_timeseries(:,:,islope,t) = Tsoil_locslope(:,:) 863 871 do ig = 1,ngrid … … 916 924 !------------------------ 917 925 write(*,*) "Adaptation of the new co2 tendencies to the current pressure" 918 call recomp_tend_co2_slope( tendencies_co2_ice,tendencies_co2_ice_ini,qsurf(:,igcm_co2,:),vmr_co2_gcm,vmr_co2_pem_phys,ps_timeseries, &919 global_ave_press_GCM,global_ave_press_new ,timelen,ngrid,nslope)926 call recomp_tend_co2_slope(ngrid,nslope,timelen,tendencies_co2_ice,tendencies_co2_ice_ini,qsurf(:,igcm_co2,:),emis,vmr_co2_gcm,vmr_co2_pem_phys,ps_timeseries, & 927 global_ave_press_GCM,global_ave_press_new) 920 928 921 929 !------------------------ -
trunk/LMDZ.COMMON/libf/evolution/pemetat0.F90
r3039 r3076 1 SUBROUTINE pemetat0(filename,ngrid,nsoil_GCM,nsoil_PEM,nslope,timelen,timestep,TI_PEM,tsoil_PEM,ice_table, ice_table_thickness, & 2 tsurf_ave_yr1,tsurf_ave_yr2,q_co2,q_h2o,ps_inst,tsoil_inst,tend_h2oglaciers,tend_co2glaciers,co2ice,waterice, & 3 global_ave_pressure,watersurf_ave,watersoil_ave, m_co2_regolith_phys,deltam_co2_regolith_phys, & 4 m_h2o_regolith_phys,deltam_h2o_regolith_phys, water_reservoir) 5 6 use iostart_PEM, only: open_startphy, close_startphy, get_field, get_var 7 use comsoil_h_PEM, only: soil_pem, layer_PEM, mlayer_PEM, fluxgeo, inertiedat_PEM, water_reservoir_nom, depth_breccia, depth_bedrock, index_breccia, index_bedrock 8 use comsoil_h, only: volcapa,inertiedat 9 use adsorption_mod, only: regolith_adsorption, adsorption_pem 10 use ice_table_mod, only: computeice_table_equilibrium 11 use constants_marspem_mod, only: alpha_clap_h2o, beta_clap_h2o, TI_breccia, TI_bedrock 12 use soil_thermalproperties_mod, only: update_soil_thermalproperties 13 use tracer_mod, only: mmol, igcm_h2o_vap ! tracer names and molar masses 1 MODULE pemetat0_mod 2 3 implicit none 4 5 !======================================================================= 6 contains 7 !======================================================================= 8 9 SUBROUTINE pemetat0(filename,ngrid,nsoil_GCM,nsoil_PEM,nslope,timelen,timestep,TI_PEM,tsoil_PEM,ice_table, ice_table_thickness, & 10 tsurf_ave_yr1,tsurf_ave_yr2,q_co2,q_h2o,ps_inst,tsoil_inst,tend_h2oglaciers,tend_co2glaciers,co2ice,waterice, & 11 global_ave_pressure,watersurf_ave,watersoil_ave, m_co2_regolith_phys,deltam_co2_regolith_phys, & 12 m_h2o_regolith_phys,deltam_h2o_regolith_phys, water_reservoir) 13 14 use iostart_PEM, only: open_startphy, close_startphy, get_field, get_var 15 use comsoil_h_PEM, only: soil_pem, layer_PEM, mlayer_PEM, fluxgeo, inertiedat_PEM, water_reservoir_nom, depth_breccia, depth_bedrock, index_breccia, index_bedrock 16 use comsoil_h, only: volcapa,inertiedat 17 use adsorption_mod, only: regolith_adsorption, adsorption_pem 18 use ice_table_mod, only: computeice_table_equilibrium 19 use constants_marspem_mod, only: alpha_clap_h2o, beta_clap_h2o, TI_breccia, TI_bedrock 20 use soil_thermalproperties_mod, only: update_soil_thermalproperties 21 use tracer_mod, only: mmol, igcm_h2o_vap ! tracer names and molar masses 22 use abort_pem_mod, only: abort_pem 23 use soil_pem_compute_mod, only: soil_pem_compute 24 use soil_pem_ini_mod, only: soil_pem_ini 14 25 15 26 #ifndef CPP_STD … … 20 31 #endif 21 32 22 implicit none 23 24 include "callkeys.h" 25 26 character(len=*), intent(in) :: filename ! name of the startfi_PEM.nc 27 integer,intent(in) :: ngrid ! # of physical grid points 28 integer,intent(in) :: nsoil_GCM ! # of vertical grid points in the GCM 29 integer,intent(in) :: nsoil_PEM ! # of vertical grid points in the PEM 30 integer,intent(in) :: nslope ! # of sub-grid slopes 31 integer,intent(in) :: timelen ! # time samples 32 real, intent(in) :: tsurf_ave_yr1(ngrid,nslope) ! surface temperature at the first year of GCM call [K] 33 real,intent(in) :: tsurf_ave_yr2(ngrid,nslope) ! surface temperature at the second year of GCM call [K] 34 real,intent(in) :: q_co2(ngrid,timelen) ! MMR tracer co2 [kg/kg] 35 real,intent(in) :: q_h2o(ngrid,timelen) ! MMR tracer h2o [kg/kg] 36 real,intent(in) :: ps_inst(ngrid,timelen) ! surface pressure [Pa] 37 real,intent(in) :: timestep ! time step [s] 38 real,intent(in) :: tend_h2oglaciers(ngrid,nslope) ! tendencies on h2o glaciers 39 real,intent(in) :: tend_co2glaciers(ngrid,nslope) ! tendencies on co2 glaciers 40 real,intent(in) :: co2ice(ngrid,nslope) ! co2 ice amount [kg/m^2] 41 real,intent(in) :: waterice(ngrid,nslope) ! water ice amount [kg/m^2] 42 real, intent(in) :: watersurf_ave(ngrid,nslope) ! surface water ice density, yearly averaged (kg/m^3) 43 real, intent(inout) :: watersoil_ave(ngrid,nsoil_PEM,nslope)! surface water ice density, yearly averaged (kg/m^3) 44 real, intent(in) :: global_ave_pressure ! mean average pressure on the planet [Pa] 33 implicit none 34 35 include "callkeys.h" 36 37 character(len=*), intent(in) :: filename ! name of the startfi_PEM.nc 38 integer, intent(in) :: ngrid ! # of physical grid points 39 integer, intent(in) :: nsoil_GCM ! # of vertical grid points in the GCM 40 integer, intent(in) :: nsoil_PEM ! # of vertical grid points in the PEM 41 integer, intent(in) :: nslope ! # of sub-grid slopes 42 integer, intent(in) :: timelen ! # time samples 43 real, intent(in) :: timestep ! time step [s] 44 real, intent(in) :: global_ave_pressure ! mean average pressure on the planet [Pa] 45 real, dimension(ngrid,nslope), intent(in) :: tsurf_ave_yr1 ! surface temperature at the first year of GCM call [K] 46 real, dimension(ngrid,nslope), intent(in) :: tsurf_ave_yr2 ! surface temperature at the second year of GCM call [K] 47 real, dimension(ngrid,timelen), intent(in) :: q_co2 ! MMR tracer co2 [kg/kg] 48 real, dimension(ngrid,timelen), intent(in) :: q_h2o ! MMR tracer h2o [kg/kg] 49 real, dimension(ngrid,timelen), intent(in) :: ps_inst ! surface pressure [Pa] 50 real, dimension(ngrid,nslope), intent(in) :: tend_h2oglaciers ! tendencies on h2o glaciers 51 real, dimension(ngrid,nslope), intent(in) :: tend_co2glaciers ! tendencies on co2 glaciers 52 real, dimension(ngrid,nslope), intent(in) :: co2ice ! co2 ice amount [kg/m^2] 53 real, dimension(ngrid,nslope), intent(in) :: waterice ! water ice amount [kg/m^2] 54 real, dimension(ngrid,nslope), intent(in) :: watersurf_ave ! surface water ice density, yearly averaged (kg/m^3) 45 55 ! outputs 46 47 real,intent(inout) :: TI_PEM(ngrid,nsoil_PEM,nslope) ! soil (mid-layer) thermal inertia in the PEM grid [SI]48 real,intent(inout) :: tsoil_PEM(ngrid,nsoil_PEM,nslope) ! soil (mid-layer) temperature [K]49 real,intent(inout) :: ice_table(ngrid,nslope) ! Ice table depth [m]50 real,intent(inout) :: ice_table_thickness(ngrid,nslope) ! Ice table thickness[m]51 real,intent(inout) :: tsoil_inst(ngrid,nsoil_PEM,nslope,timelen) ! instantaneous soil (mid-layer) temperature [K]52 real,intent(inout) :: m_co2_regolith_phys(ngrid,nsoil_PEM,nslope) ! mass of co2 adsorbed [kg/m^2]53 real,intent(out) :: deltam_co2_regolith_phys(ngrid) ! mass of co2 that is exchanged due to adsorption desorption[kg/m^2]54 real,intent(inout) :: m_h2o_regolith_phys(ngrid,nsoil_PEM,nslope)! mass of h2o adsorbed [kg/m^2]55 real,intent(out) :: deltam_h2o_regolith_phys(ngrid)! mass of h2o that is exchanged due to adsorption desorption [kg/m^2]56 real,intent(inout) :: water_reservoir(ngrid) ! mass of h2o that is exchanged due to adsorption desorption [kg/m^2] 56 real, dimension(ngrid), intent(out) :: deltam_co2_regolith_phys ! mass of co2 that is exchanged due to adsorption desorption [kg/m^2] 57 real, dimension(ngrid), intent(out) :: deltam_h2o_regolith_phys ! mass of h2o that is exchanged due to adsorption desorption [kg/m^2] 58 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: TI_PEM ! soil (mid-layer) thermal inertia in the PEM grid [SI] 59 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: tsoil_PEM ! soil (mid-layer) temperature [K] 60 real, dimension(ngrid,nslope), intent(inout) :: ice_table ! Ice table depth [m] 61 real, dimension(ngrid,nslope), intent(inout) :: ice_table_thickness ! Ice table thickness [m] 62 real, dimension(ngrid,nsoil_PEM,nslope,timelen), intent(inout) :: tsoil_inst ! instantaneous soil (mid-layer) temperature [K] 63 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_co2_regolith_phys ! mass of co2 adsorbed [kg/m^2] 64 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: m_h2o_regolith_phys ! mass of h2o adsorbed [kg/m^2] 65 real, dimension(ngrid), intent(inout) :: water_reservoir ! mass of h2o that is exchanged due to adsorption desorption [kg/m^2] 66 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: watersoil_ave ! surface water ice density, yearly averaged (kg/m^3) 57 67 ! local 58 real :: tsoil_startPEM(ngrid,nsoil_PEM,nslope)! soil temperature saved in the start [K]59 real :: TI_startPEM(ngrid,nsoil_PEM,nslope)! soil thermal inertia saved in the start [SI]60 LOGICAL :: found! check if variables are found in the start61 LOGICAL :: found2! check if variables are found in the start62 integer :: iloop,ig,islope,it,isoil! index for loops63 real :: kcond! Thermal conductivity, intermediate variable [SI]64 real :: delta! Depth of the interface regolith-breccia, breccia -bedrock [m]65 CHARACTER*2 :: num! intermediate string to read PEM start sloped variables66 real :: tsoil_saved(ngrid,nsoil_PEM)! saved soil temperature [K]67 real :: tsoil_tmp_yr1(ngrid,nsoil_PEM,nslope)! intermediate soil temperature during yr1[K]68 real :: tsoil_tmp_yr2(ngrid,nsoil_PEM,nslope)! intermediate soil temperature during yr 2 [K]69 real :: alph_tmp(ngrid,nsoil_PEM-1)! Intermediate for tsoil computation []70 real :: beta_tmp(ngrid,nsoil_PEM-1) ! Intermediate for tsoil computatio [] 71 LOGICAL :: startpem_file! boolean to check if we read the startfile or not72 #ifdef CPP_STD 73 logical :: watercaptag(ngrid) 74 75 watercaptag(:) =.false.68 real, dimension(ngrid,nsoil_PEM,nslope) :: tsoil_startPEM ! soil temperature saved in the start [K] 69 real, dimension(ngrid,nsoil_PEM,nslope) :: TI_startPEM ! soil thermal inertia saved in the start [SI] 70 logical :: found ! check if variables are found in the start 71 logical :: found2 ! check if variables are found in the start 72 integer :: iloop, ig, islope, it, isoil ! index for loops 73 real :: kcond ! Thermal conductivity, intermediate variable [SI] 74 real :: delta ! Depth of the interface regolith-breccia, breccia -bedrock [m] 75 character(2) :: num ! intermediate string to read PEM start sloped variables 76 real, dimension(ngrid,nsoil_PEM) :: tsoil_saved ! saved soil temperature [K] 77 real, dimension(ngrid,nsoil_PEM,nslope) :: tsoil_tmp_yr1 ! intermediate soil temperature during yr1[K] 78 real, dimension(ngrid,nsoil_PEM,nslope) :: tsoil_tmp_yr2 ! intermediate soil temperature during yr 2 [K] 79 real, dimension(ngrid,nsoil_PEM - 1) :: alph_tmp ! Intermediate for tsoil computation [] 80 real, dimension(ngrid,nsoil_PEM - 1) :: beta_tmp ! Intermediate for tsoil computatio [] 81 logical :: startpem_file ! boolean to check if we read the startfile or not 82 83 #ifdef CPP_STD 84 logical, dimension(ngrid) :: watercaptag 85 watercaptag(:) = .false. 76 86 #endif 77 87 … … 81 91 !!! 82 92 !!! Order: 0. Previous year of the PEM run 83 !!! 1. Thermal Inertia 93 !!! 1. Thermal Inertia 84 94 !!! 2. Soil Temperature 85 95 !!! 3. Ice table … … 99 109 100 110 !1. Run 101 102 111 if (startpem_file) then 103 ! open pem initial state file:104 call open_startphy(filename)112 ! open pem initial state file: 113 call open_startphy(filename) 105 114 106 115 if (soil_pem) then 107 116 108 117 !1. Thermal Inertia 109 118 ! a. General case 110 111 DO islope=1,nslope 112 write(num,fmt='(i2.2)') islope 113 call get_field("TI_PEM_slope"//num,TI_startPEM(:,:,islope),found) 114 if(.not.found) then 115 write(*,*)'PEM settings: failed loading <TI_PEM_slope'//num//'>' 116 write(*,*)'will reconstruct the values of TI_PEM' 117 118 do ig = 1,ngrid 119 if(TI_PEM(ig,index_breccia,islope).lt.TI_breccia) then 120 !!! transition 121 delta = depth_breccia 122 TI_PEM(ig,index_breccia+1,islope) = sqrt((layer_PEM(index_breccia+1)-layer_PEM(index_breccia))/ & 123 (((delta-layer_PEM(index_breccia))/(TI_PEM(ig,index_breccia,islope)**2))+ & 124 ((layer_PEM(index_breccia+1)-delta)/(TI_breccia**2)))) 125 do iloop=index_breccia+2,index_bedrock 126 TI_PEM(ig,iloop,islope) = TI_breccia 127 enddo 128 else ! we keep the high ti values 129 do iloop=index_breccia+1,index_bedrock 130 TI_PEM(ig,iloop,islope) = TI_PEM(ig,index_breccia,islope) 131 enddo 132 endif ! TI PEM and breccia comparison 133 !! transition 134 delta = depth_bedrock 135 TI_PEM(ig,index_bedrock+1,islope) = sqrt((layer_PEM(index_bedrock+1)-layer_PEM(index_bedrock))/ & 136 (((delta-layer_PEM(index_bedrock))/(TI_PEM(ig,index_bedrock,islope)**2))+ & 137 ((layer_PEM(index_bedrock+1)-delta)/(TI_bedrock**2)))) 138 do iloop=index_bedrock+2,nsoil_PEM 139 TI_PEM(ig,iloop,islope) = TI_bedrock 140 enddo 141 enddo 142 else ! found 143 do iloop = nsoil_GCM+1,nsoil_PEM 144 TI_PEM(:,iloop,islope) = TI_startPEM(:,iloop,islope) ! ! 1st layers can change because of the presence of ice at the surface, so we don't change it here. 145 enddo 146 endif ! not found 147 ENDDO ! islope 148 149 write(*,*) 'PEMETAT0: THERMAL INERTIA DONE' 119 do islope = 1,nslope 120 write(num,'(i2.2)') islope 121 call get_field("TI_PEM_slope"//num,TI_startPEM(:,:,islope),found) 122 if (.not. found) then 123 write(*,*)'PEM settings: failed loading <TI_PEM_slope'//num//'>' 124 write(*,*)'will reconstruct the values of TI_PEM' 125 126 do ig = 1,ngrid 127 if (TI_PEM(ig,index_breccia,islope) < TI_breccia) then 128 !!! transition 129 delta = depth_breccia 130 TI_PEM(ig,index_breccia+1,islope) = sqrt((layer_PEM(index_breccia + 1) - layer_PEM(index_breccia))/ & 131 (((delta - layer_PEM(index_breccia))/(TI_PEM(ig,index_breccia,islope)**2)) + & 132 ((layer_PEM(index_breccia + 1) - delta)/(TI_breccia**2)))) 133 do iloop=index_breccia+2,index_bedrock 134 TI_PEM(ig,iloop,islope) = TI_breccia 135 enddo 136 else ! we keep the high ti values 137 do iloop = index_breccia + 1,index_bedrock 138 TI_PEM(ig,iloop,islope) = TI_PEM(ig,index_breccia,islope) 139 enddo 140 endif ! TI PEM and breccia comparison 141 !! transition 142 delta = depth_bedrock 143 TI_PEM(ig,index_bedrock + 1,islope) = sqrt((layer_PEM(index_bedrock + 1) - layer_PEM(index_bedrock))/ & 144 (((delta - layer_PEM(index_bedrock))/(TI_PEM(ig,index_bedrock,islope)**2)) + & 145 ((layer_PEM(index_bedrock + 1) - delta)/(TI_bedrock**2)))) 146 do iloop = index_bedrock + 2,nsoil_PEM 147 TI_PEM(ig,iloop,islope) = TI_bedrock 148 enddo 149 enddo 150 else ! found 151 do iloop = nsoil_GCM + 1,nsoil_PEM 152 TI_PEM(:,iloop,islope) = TI_startPEM(:,iloop,islope) ! ! 1st layers can change because of the presence of ice at the surface, so we don't change it here. 153 enddo 154 endif ! not found 155 enddo ! islope 156 157 write(*,*) 'PEMETAT0: THERMAL INERTIA doNE' 150 158 151 159 ! b. Special case for inertiedat, inertiedat_PEM … … 154 162 do iloop = 1,nsoil_GCM 155 163 inertiedat_PEM(:,iloop) = inertiedat(:,iloop) 156 enddo 164 enddo 157 165 !!! zone de transition 158 166 delta = depth_breccia 159 167 do ig = 1,ngrid 160 if(inertiedat_PEM(ig,index_breccia).lt.TI_breccia) then 168 if(inertiedat_PEM(ig,index_breccia).lt.TI_breccia) then 161 169 inertiedat_PEM(ig,index_breccia+1) = sqrt((layer_PEM(index_breccia+1)-layer_PEM(index_breccia))/ & 162 170 (((delta-layer_PEM(index_breccia))/(inertiedat(ig,index_breccia)**2))+ & 163 171 ((layer_PEM(index_breccia+1)-delta)/(TI_breccia**2)))) 164 172 165 do iloop = index_breccia+2,index_bedrock 173 do iloop = index_breccia+2,index_bedrock 166 174 inertiedat_PEM(ig,iloop) = TI_breccia 167 175 enddo … … 170 178 do iloop=index_breccia+1,index_bedrock 171 179 inertiedat_PEM(ig,iloop) = inertiedat_PEM(ig,nsoil_GCM) 172 enddo 180 enddo 173 181 endif ! comparison ti breccia 174 182 enddo!ig … … 189 197 endif ! not found 190 198 191 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!199 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 192 200 !2. Soil Temperature 193 DOislope=1,nslope201 do islope=1,nslope 194 202 write(num,fmt='(i2.2)') islope 195 203 call get_field("tsoil_PEM_slope"//num,tsoil_startPEM(:,:,islope),found) … … 199 207 ! do ig = 1,ngrid 200 208 ! kcond = (TI_PEM(ig,index_breccia+1,islope)*TI_PEM(ig,index_breccia+1,islope))/volcapa 201 ! tsoil_PEM(ig,index_breccia+1,islope) = tsoil_PEM(ig,index_breccia,islope) + fluxgeo/kcond*(mlayer_PEM(index_breccia)-mlayer_PEM(index_breccia-1)) 209 ! tsoil_PEM(ig,index_breccia+1,islope) = tsoil_PEM(ig,index_breccia,islope) + fluxgeo/kcond*(mlayer_PEM(index_breccia)-mlayer_PEM(index_breccia-1)) 202 210 ! do iloop=index_breccia+2,index_bedrock 203 211 ! kcond = (TI_PEM(ig,iloop,islope)*TI_PEM(ig,iloop,islope))/volcapa … … 205 213 ! enddo 206 214 ! kcond = (TI_PEM(ig,index_bedrock+1,islope)*TI_PEM(ig,index_bedrock+1,islope))/volcapa 207 ! tsoil_PEM(ig,index_bedrock+1,islope) = tsoil_PEM(ig,index_bedrock,islope) + fluxgeo/kcond*(mlayer_PEM(index_bedrock)-mlayer_PEM(index_bedrock-1)) 215 ! tsoil_PEM(ig,index_bedrock+1,islope) = tsoil_PEM(ig,index_bedrock,islope) + fluxgeo/kcond*(mlayer_PEM(index_bedrock)-mlayer_PEM(index_bedrock-1)) 208 216 ! 209 217 ! do iloop=index_bedrock+2,nsoil_PEM … … 215 223 216 224 call soil_pem_ini(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_ave_yr2(:,islope),tsoil_PEM(:,:,islope)) 217 call soil_pem_ routine(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr2(:,islope),tsoil_PEM(:,:,islope))218 219 225 call soil_pem_compute(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr2(:,islope),tsoil_PEM(:,:,islope)) 226 227 220 228 else 221 229 ! predictor corrector: restart from year 1 of the GCM and build the evolution of … … 223 231 224 232 tsoil_tmp_yr1(:,:,islope) = tsoil_startPEM(:,:,islope) 225 call soil_pem_ routine(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr1(:,islope),tsoil_tmp_yr1(:,:,islope))226 call soil_pem_ routine(ngrid,nsoil_PEM,.false.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr1(:,islope),tsoil_tmp_yr1(:,:,islope))227 tsoil_tmp_yr2(:,:,islope) = tsoil_tmp_yr1(:,:,islope) 228 call soil_pem_ routine(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr2(:,islope),tsoil_tmp_yr2(:,:,islope))233 call soil_pem_compute(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr1(:,islope),tsoil_tmp_yr1(:,:,islope)) 234 call soil_pem_compute(ngrid,nsoil_PEM,.false.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr1(:,islope),tsoil_tmp_yr1(:,:,islope)) 235 tsoil_tmp_yr2(:,:,islope) = tsoil_tmp_yr1(:,:,islope) 236 call soil_pem_compute(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr2(:,islope),tsoil_tmp_yr2(:,:,islope)) 229 237 230 238 … … 244 252 enddo 245 253 enddo 246 ENDDO! islope247 248 write(*,*) 'PEMETAT0: SOIL TEMP DONE'249 250 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!254 enddo ! islope 255 256 write(*,*) 'PEMETAT0: SOIL TEMP doNE' 257 258 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 251 259 !3. Ice Table 252 260 call get_field("ice_table",ice_table,found) … … 261 269 endif 262 270 263 write(*,*) 'PEMETAT0: ICE TABLE DONE'264 265 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!271 write(*,*) 'PEMETAT0: ICE TABLE doNE' 272 273 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 266 274 !4. CO2 & H2O Adsorption 267 275 if(adsorption_pem) then 268 DOislope=1,nslope276 do islope=1,nslope 269 277 write(num,fmt='(i2.2)') islope 270 278 call get_field("mco2_reg_ads_slope"//num,m_co2_regolith_phys(:,:,islope),found) … … 273 281 exit 274 282 endif 275 276 ENDDO277 278 DOislope=1,nslope283 284 enddo 285 286 do islope=1,nslope 279 287 write(num,fmt='(i2.2)') islope 280 288 call get_field("mh2o_reg_ads_slope"//num,m_h2o_regolith_phys(:,:,islope),found2) … … 283 291 exit 284 292 endif 285 286 ENDDO293 294 enddo 287 295 288 296 call regolith_adsorption(ngrid,nslope,nsoil_PEM,timelen,tend_h2oglaciers,tend_co2glaciers,waterice,co2ice,tsoil_PEM,TI_PEM,ps_inst,q_co2,q_h2o, & … … 293 301 endif 294 302 if((.not.found2)) then 295 deltam_h2o_regolith_phys(:) = 0. 303 deltam_h2o_regolith_phys(:) = 0. 296 304 endif 297 write(*,*) 'PEMETAT0: CO2 & H2O adsorption DONE'305 write(*,*) 'PEMETAT0: CO2 & H2O adsorption doNE' 298 306 endif 299 307 endif ! soil_pem 300 308 301 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!309 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 302 310 !. 5 water reservoir 303 #ifndef CPP_STD 311 #ifndef CPP_STD 304 312 call get_field("water_reservoir",water_reservoir,found) 305 313 if(.not.found) then … … 326 334 do ig = 1,ngrid 327 335 328 if(TI_PEM(ig,index_breccia,islope).lt.TI_breccia) then 336 if(TI_PEM(ig,index_breccia,islope).lt.TI_breccia) then 329 337 !!! transition 330 338 delta = depth_breccia … … 335 343 do iloop=index_breccia+2,index_bedrock 336 344 TI_PEM(ig,iloop,islope) = TI_breccia 337 enddo 345 enddo 338 346 else ! we keep the high ti values 339 347 do iloop=index_breccia+1,index_bedrock 340 348 TI_PEM(ig,iloop,islope) = TI_PEM(ig,index_breccia,islope) 341 enddo 349 enddo 342 350 endif 343 351 … … 349 357 do iloop=index_bedrock+2,nsoil_PEM 350 358 TI_PEM(ig,iloop,islope) = TI_bedrock 351 enddo 359 enddo 352 360 enddo 353 361 enddo … … 357 365 enddo 358 366 !!! zone de transition 359 delta = depth_breccia 367 delta = depth_breccia 360 368 do ig = 1,ngrid 361 if(inertiedat_PEM(ig,index_breccia).lt.TI_breccia) then 369 if(inertiedat_PEM(ig,index_breccia).lt.TI_breccia) then 362 370 inertiedat_PEM(ig,index_breccia+1) = sqrt((layer_PEM(index_breccia+1)-layer_PEM(index_breccia))/ & 363 371 (((delta-layer_PEM(index_breccia))/(inertiedat(ig,index_breccia)**2))+ & … … 365 373 366 374 367 do iloop = index_breccia+2,index_bedrock 375 do iloop = index_breccia+2,index_bedrock 368 376 369 377 inertiedat_PEM(ig,iloop) = TI_breccia 370 378 371 379 enddo 372 else 373 do iloop = index_breccia+1,index_bedrock 380 else 381 do iloop = index_breccia+1,index_bedrock 374 382 inertiedat_PEM(ig,iloop) = inertiedat_PEM(ig,index_breccia) 375 383 enddo … … 394 402 enddo 395 403 396 write(*,*) 'PEMETAT0: TI DONE'397 398 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!399 !b) Soil temperature 404 write(*,*) 'PEMETAT0: TI doNE' 405 406 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 407 !b) Soil temperature 400 408 do islope = 1,nslope 401 409 ! do ig = 1,ngrid … … 414 422 ! tsoil_PEM(ig,iloop,islope) = tsoil_PEM(ig,index_bedrock+1,islope) + fluxgeo/kcond*(mlayer_PEM(iloop-1)-mlayer_PEM(index_bedrock)) 415 423 ! enddo 416 424 417 425 ! enddo 418 426 419 427 call soil_pem_ini(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_ave_yr2(:,islope),tsoil_PEM(:,:,islope)) 420 call soil_pem_ routine(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr2(:,islope),tsoil_PEM(:,:,islope))421 422 428 call soil_pem_compute(ngrid,nsoil_PEM,.true.,TI_PEM(:,:,islope),timestep,tsurf_ave_yr2(:,islope),tsoil_PEM(:,:,islope)) 429 430 423 431 do it = 1,timelen 424 432 do isoil = nsoil_GCM+1,nsoil_PEM … … 433 441 enddo 434 442 enddo !islope 435 write(*,*) 'PEMETAT0: TSOIL DONE'436 437 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!443 write(*,*) 'PEMETAT0: TSOIL doNE' 444 445 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 438 446 !c) Ice table 439 447 call computeice_table_equilibrium(ngrid,nslope,nsoil_PEM,watercaptag,watersurf_ave,watersoil_ave,TI_PEM(:,1,:),ice_table,ice_table_thickness) … … 442 450 call soil_pem_ini(ngrid,nsoil_PEM,TI_PEM(:,:,islope),tsurf_ave_yr2(:,islope),tsoil_PEM(:,:,islope)) 443 451 enddo 444 write(*,*) 'PEMETAT0: Ice table DONE'445 446 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!452 write(*,*) 'PEMETAT0: Ice table doNE' 453 454 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 447 455 !d) Regolith adsorbed 448 if(adsorption_pem) then456 if (adsorption_pem) then 449 457 m_co2_regolith_phys(:,:,:) = 0. 450 458 m_h2o_regolith_phys(:,:,:) = 0. 451 459 452 460 call regolith_adsorption(ngrid,nslope,nsoil_PEM,timelen,tend_h2oglaciers,tend_co2glaciers,waterice,co2ice,tsoil_PEM,TI_PEM,ps_inst,q_co2,q_h2o, & 453 454 461 m_h2o_regolith_phys,deltam_h2o_regolith_phys, m_co2_regolith_phys,deltam_co2_regolith_phys) 462 455 463 deltam_co2_regolith_phys(:) = 0. 456 deltam_h2o_regolith_phys(:) = 0. 457 458 459 write(*,*) 'PEMETAT0: CO2 adsorption DONE'464 deltam_h2o_regolith_phys(:) = 0. 465 endif 466 467 write(*,*) 'PEMETAT0: CO2 adsorption doNE' 460 468 endif !soil_pem 461 469 462 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!470 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 463 471 !. e) water reservoir 464 #ifndef CPP_STD 465 do ig=1,ngrid466 if (watercaptag(ig)) then467 water_reservoir(ig)=water_reservoir_nom472 #ifndef CPP_STD 473 do ig = 1,ngrid 474 if (watercaptag(ig)) then 475 water_reservoir(ig) = water_reservoir_nom 468 476 else 469 water_reservoir(ig)=0.477 water_reservoir(ig) = 0. 470 478 endif 471 479 enddo 472 480 #endif 473 481 474 482 endif ! of if (startphy_file) 475 483 476 if(soil_pem) then 477 !! Sanity check 478 DO ig = 1,ngrid 479 DO islope = 1,nslope 480 DO iloop = 1,nsoil_PEM 481 if (isnan(tsoil_PEM(ig,iloop,islope))) call abort_pem("PEM - pemetat0","NaN detected in Tsoil",1) 482 ENDDO 483 ENDDO 484 ENDDO 485 endif!soil_pem 486 487 END SUBROUTINE 484 if (soil_pem) then ! Sanity check 485 do ig = 1,ngrid 486 do islope = 1,nslope 487 do iloop = 1,nsoil_PEM 488 if (isnan(tsoil_PEM(ig,iloop,islope))) call abort_pem("PEM - pemetat0","NaN detected in Tsoil",1) 489 enddo 490 enddo 491 enddo 492 endif !soil_pem 493 494 END SUBROUTINE pemetat0 495 496 END MODULE pemetat0_mod 497 -
trunk/LMDZ.COMMON/libf/evolution/read_data_GCM_mod.F90
r3075 r3076 1 SUBROUTINE read_data_GCM(fichnom,timelen, iim_input,jjm_input,ngrid,nslope,vmr_co2_gcm_phys,ps_timeseries, & 2 min_co2_ice,min_h2o_ice,tsurf_ave,tsoil_ave,tsurf_gcm,tsoil_gcm,q_co2,q_h2o,co2_ice_slope, & 3 watersurf_density_ave,watersoil_density) 4 5 use netcdf, only: nf90_open,NF90_NOWRITE,nf90_noerr,nf90_strerror, & 6 nf90_get_var, nf90_inq_varid, nf90_inq_dimid, & 7 nf90_inquire_dimension,nf90_close 8 use comsoil_h, only: nsoilmx 9 USE comsoil_h_PEM, ONLY: soil_pem 10 use constants_marspem_mod,only: m_co2,m_noco2 11 IMPLICIT NONE 1 MODULE read_data_GCM_mod 2 3 use netcdf, only: nf90_open, NF90_NOWRITE, nf90_noerr, nf90_strerror, & 4 nf90_get_var, nf90_inq_varid, nf90_inq_dimid, & 5 nf90_inquire_dimension, nf90_close 6 7 implicit none 8 9 character(256) :: msg, var, modname ! for reading 10 integer :: fID, vID ! for reading 11 12 !======================================================================= 13 contains 14 !======================================================================= 15 16 SUBROUTINE read_data_GCM(fichnom,timelen,iim_input,jjm_input,ngrid,nslope,vmr_co2_gcm_phys,ps_timeseries, & 17 min_co2_ice,min_h2o_ice,tsurf_ave,tsoil_ave,tsurf_gcm,tsoil_gcm,q_co2,q_h2o,co2_ice_slope, & 18 watersurf_density_ave,watersoil_density) 19 use comsoil_h, only: nsoilmx 20 use comsoil_h_PEM, only: soil_pem 21 use constants_marspem_mod, only: m_co2, m_noco2 22 23 implicit none 12 24 13 25 !======================================================================= … … 18 30 !======================================================================= 19 31 20 include "dimensions.h" 21 32 include "dimensions.h" 33 34 !======================================================================= 35 ! Arguments: 36 37 character(len = *), intent(in) :: fichnom !--- FILE NAME 38 integer, intent(in) :: timelen ! number of times stored in the file 39 integer :: iim_input, jjm_input, ngrid, nslope ! number of points in the lat x lon dynamical grid, number of subgrid slopes 40 ! Ouputs 41 real, dimension(ngrid,nslope), intent(out) :: min_co2_ice ! Minimum of co2 ice per slope of the year [kg/m^2] 42 real, dimension(ngrid,nslope), intent(out) :: min_h2o_ice ! Minimum of h2o ice per slope of the year [kg/m^2] 43 real, dimension(ngrid,timelen), intent(out) :: vmr_co2_gcm_phys ! Physics x Times co2 volume mixing ratio retrieve from the gcm [m^3/m^3] 44 real, dimension(ngrid,timelen), intent(out) :: ps_timeseries ! Surface Pressure [Pa] 45 real, dimension(ngrid,timelen), intent(out) :: q_co2 ! CO2 mass mixing ratio in the first layer [kg/m^3] 46 real, dimension(ngrid,timelen), intent(out) :: q_h2o ! H2O mass mixing ratio in the first layer [kg/m^3] 47 real, dimension(ngrid,nslope,timelen), intent(out) :: co2_ice_slope ! co2 ice amount per slope of the year [kg/m^2] 48 !SOIL 49 real, dimension(ngrid,nslope), intent(out) :: tsurf_ave ! Average surface temperature of the concatenated file [K] 50 real, dimension(ngrid,nsoilmx,nslope), intent(out) :: tsoil_ave ! Average soil temperature of the concatenated file [K] 51 real, dimension(ngrid,nslope,timelen), intent(out) :: tsurf_gcm ! Surface temperature of the concatenated file, time series [K] 52 real, dimension(ngrid,nsoilmx,nslope,timelen), intent(out) :: tsoil_gcm ! Soil temperature of the concatenated file, time series [K] 53 real, dimension(ngrid,nslope), intent(out) :: watersurf_density_ave ! Water density at the surface [kg/m^3] 54 real, dimension(ngrid,nsoilmx,nslope,timelen), intent(out) :: watersoil_density ! Water density in the soil layer, time series [kg/m^3] 22 55 !=============================================================================== 23 ! Arguments: 24 25 CHARACTER(LEN=*), INTENT(IN) :: fichnom !--- FILE NAME 26 INTEGER, INTENT(IN) :: timelen ! number of times stored in the file 27 INTEGER :: iim_input,jjm_input,ngrid,nslope ! number of points in the lat x lon dynamical grid, number of subgrid slopes 28 ! Ouputs 29 REAL, INTENT(OUT) :: min_co2_ice(ngrid,nslope) ! Minimum of co2 ice per slope of the year [kg/m^2] 30 REAL, INTENT(OUT) :: min_h2o_ice(ngrid,nslope) ! Minimum of h2o ice per slope of the year [kg/m^2] 31 REAL, INTENT(OUT) :: vmr_co2_gcm_phys(ngrid,timelen) ! Physics x Times co2 volume mixing ratio retrieve from the gcm [m^3/m^3] 32 REAL, INTENT(OUT) :: ps_timeseries(ngrid,timelen)! Surface Pressure [Pa] 33 REAL, INTENT(OUT) :: q_co2(ngrid,timelen) ! CO2 mass mixing ratio in the first layer [kg/m^3] 34 REAL, INTENT(OUT) :: q_h2o(ngrid,timelen) ! H2O mass mixing ratio in the first layer [kg/m^3] 35 REAL, INTENT(OUT) :: co2_ice_slope(ngrid,nslope,timelen) ! co2 ice amount per slope of the year [kg/m^2] 36 !SOIL 37 REAL, INTENT(OUT) :: tsurf_ave(ngrid,nslope) ! Average surface temperature of the concatenated file [K] 38 REAL, INTENT(OUT) :: tsoil_ave(ngrid,nsoilmx,nslope) ! Average soil temperature of the concatenated file [K] 39 REAL ,INTENT(OUT) :: tsurf_gcm(ngrid,nslope,timelen) ! Surface temperature of the concatenated file, time series [K] 40 REAL , INTENT(OUT) :: tsoil_gcm(ngrid,nsoilmx,nslope,timelen) ! Soil temperature of the concatenated file, time series [K] 41 REAL , INTENT(OUT) :: watersurf_density_ave(ngrid,nslope) ! Water density at the surface [kg/m^3] 42 REAL , INTENT(OUT) :: watersoil_density(ngrid,nsoilmx,nslope,timelen) ! Water density in the soil layer, time series [kg/m^3] 43 !=============================================================================== 44 ! Local Variables 45 CHARACTER(LEN=256) :: msg, var, modname ! for reading 46 INTEGER :: iq, fID, vID, idecal ! for reading 47 INTEGER :: ierr ! for reading 48 CHARACTER(len=12) :: start_file_type="earth" ! default start file type 49 50 REAL,ALLOCATABLE :: time(:) ! times stored in start 51 INTEGER :: indextime ! index of selected time 52 53 INTEGER :: edges(4),corner(4) 54 INTEGER :: i,j,l,t ! loop variables 55 real :: A , B, mmean ! Molar Mass of co2 and no co2, A;B intermediate variables to compute the mean molar mass of the layer 56 57 INTEGER :: islope ! loop for variables 58 CHARACTER*2 :: num ! for reading sloped variables 59 REAL :: h2o_ice_s_dyn(iim_input+1,jjm_input+1,nslope,timelen) ! h2o ice per slope of the concatenated file [kg/m^2] 60 REAL :: watercap_slope(iim_input+1,jjm_input+1,nslope,timelen) 61 REAL :: vmr_co2_gcm(iim_input+1,jjm_input+1,timelen) ! CO2 volume mixing ratio in the first layer [mol/m^3] 62 REAL :: ps_GCM(iim_input+1,jjm_input+1,timelen) ! Surface Pressure [Pa] 63 REAL :: min_co2_ice_dyn(iim_input+1,jjm_input+1,nslope) 64 REAL :: min_h2o_ice_dyn(iim_input+1,jjm_input+1,nslope) 65 REAL :: tsurf_ave_dyn(iim_input+1,jjm_input+1,nslope) ! Average surface temperature of the concatenated file [K] 66 REAL :: tsoil_ave_dyn(iim_input+1,jjm_input+1,nsoilmx,nslope) ! Average soil temperature of the concatenated file [K] 67 REAL :: tsurf_gcm_dyn(iim_input+1,jjm_input+1,nslope,timelen) ! Surface temperature of the concatenated file, time series [K] 68 REAL :: tsoil_gcm_dyn(iim_input+1,jjm_input+1,nsoilmx,nslope,timelen)! Soil temperature of the concatenated file, time series [K] 69 REAL :: q_co2_dyn(iim_input+1,jjm_input+1,timelen) ! CO2 mass mixing ratio in the first layer [kg/m^3] 70 REAL :: q_h2o_dyn(iim_input+1,jjm_input+1,timelen) ! H2O mass mixing ratio in the first layer [kg/m^3] 71 REAL :: co2_ice_slope_dyn(iim_input+1,jjm_input+1,nslope,timelen) ! co2 ice amount per slope of the year [kg/m^2] 72 REAL :: watersurf_density_dyn(iim_input+1,jjm_input+1,nslope,timelen)! Water density at the surface, time series [kg/m^3] 73 REAL :: watersurf_density(ngrid,nslope,timelen) ! Water density at the surface, time series [kg/m^3] 74 REAL :: watersoil_density_dyn(iim_input+1,jjm_input+1,nsoilmx,nslope,timelen) ! Water density in the soil layer, time series [kg/m^3] 56 ! Local Variables 57 character(12) :: start_file_type = "earth" ! default start file type 58 real, dimension(:), allocatable :: time ! times stored in start 59 integer :: indextime ! index of selected time 60 integer :: edges(4), corner(4) 61 integer :: i, j, l, t ! loop variables 62 real :: A , B, mmean ! Molar Mass of co2 and no co2, A;B intermediate variables to compute the mean molar mass of the layer 63 integer :: islope ! loop for variables 64 character(2) :: num ! for reading sloped variables 65 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: h2o_ice_s_dyn ! h2o ice per slope of the concatenated file [kg/m^2] 66 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: watercap_slope 67 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: vmr_co2_gcm ! CO2 volume mixing ratio in the first layer [mol/m^3] 68 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: ps_GCM ! Surface Pressure [Pa] 69 real, dimension(iim_input + 1,jjm_input + 1,nslope) :: min_co2_ice_dyn 70 real, dimension(iim_input + 1,jjm_input + 1,nslope) :: min_h2o_ice_dyn 71 real, dimension(iim_input + 1,jjm_input + 1,nslope) :: tsurf_ave_dyn ! Average surface temperature of the concatenated file [K] 72 real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope) :: tsoil_ave_dyn ! Average soil temperature of the concatenated file [K] 73 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: tsurf_gcm_dyn ! Surface temperature of the concatenated file, time series [K] 74 real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope,timelen) :: tsoil_gcm_dyn ! Soil temperature of the concatenated file, time series [K] 75 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: q_co2_dyn ! CO2 mass mixing ratio in the first layer [kg/m^3] 76 real, dimension(iim_input + 1,jjm_input + 1,timelen) :: q_h2o_dyn ! H2O mass mixing ratio in the first layer [kg/m^3] 77 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: co2_ice_slope_dyn ! co2 ice amount per slope of the year [kg/m^2] 78 real, dimension(iim_input + 1,jjm_input + 1,nslope,timelen) :: watersurf_density_dyn ! Water density at the surface, time series [kg/m^3] 79 real, dimension(iim_input + 1,jjm_input + 1,nsoilmx,nslope,timelen) :: watersoil_density_dyn ! Water density in the soil layer, time series [kg/m^3] 80 real, dimension(ngrid,nslope,timelen) :: watersurf_density ! Water density at the surface, time series [kg/m^3] 75 81 76 82 !----------------------------------------------------------------------- 77 78 79 A =(1/m_co2 - 1/m_noco2)80 B=1/m_noco281 82 83 modname="read_data_gcm" 84 85 A = (1/m_co2 - 1/m_noco2) 86 B = 1/m_noco2 87 88 write(*,*) "Opening ", fichnom, "..." 83 89 84 90 ! Open initial state NetCDF file 85 var=fichnom 86 CALL err(NF90_OPEN(var,NF90_NOWRITE,fID),"open",var) 87 88 write(*,*) "Downloading data for vmr co2..." 89 90 CALL get_var3("co2_layer1" ,q_co2_dyn) 91 92 write(*,*) "Downloading data for vmr co2 done" 93 write(*,*) "Downloading data for vmr h20..." 94 95 CALL get_var3("h2o_layer1" ,q_h2o_dyn) 96 97 write(*,*) "Downloading data for vmr h2o done" 98 write(*,*) "Downloading data for surface pressure ..." 99 100 CALL get_var3("ps" ,ps_GCM) 101 102 write(*,*) "Downloading data for surface pressure done" 103 write(*,*) "nslope=", nslope 104 105 if(nslope.gt.1) then 106 107 write(*,*) "Downloading data for co2ice_slope ..." 108 109 DO islope=1,nslope 110 write(num,fmt='(i2.2)') islope 111 call get_var3("co2ice_slope"//num,co2_ice_slope_dyn(:,:,islope,:)) 112 ENDDO 113 114 write(*,*) "Downloading data for co2ice_slope done" 115 write(*,*) "Downloading data for h2o_ice_s_slope ..." 116 117 DO islope=1,nslope 118 write(num,fmt='(i2.2)') islope 119 call get_var3("h2o_ice_s_slope"//num,h2o_ice_s_dyn(:,:,islope,:)) 120 ENDDO 121 122 write(*,*) "Downloading data for h2o_ice_s_slope done" 91 var = fichnom 92 call error_msg(NF90_OPEN(var,NF90_NOWRITE,fID),"open",var) 93 94 write(*,*) "Downloading data for vmr co2..." 95 96 call get_var3("co2_layer1" ,q_co2_dyn) 97 98 write(*,*) "Downloading data for vmr co2 done" 99 write(*,*) "Downloading data for vmr h20..." 100 101 call get_var3("h2o_layer1" ,q_h2o_dyn) 102 103 write(*,*) "Downloading data for vmr h2o done" 104 write(*,*) "Downloading data for surface pressure ..." 105 106 call get_var3("ps" ,ps_GCM) 107 108 write(*,*) "Downloading data for surface pressure done" 109 write(*,*) "nslope=", nslope 110 111 if (nslope > 1) then 112 write(*,*) "Downloading data for co2ice_slope ..." 113 114 do islope = 1,nslope 115 write(num,'(i2.2)') islope 116 call get_var3("co2ice_slope"//num,co2_ice_slope_dyn(:,:,islope,:)) 117 enddo 118 119 write(*,*) "Downloading data for co2ice_slope done" 120 write(*,*) "Downloading data for h2o_ice_s_slope ..." 121 122 do islope = 1,nslope 123 write(num,'(i2.2)') islope 124 call get_var3("h2o_ice_s_slope"//num,h2o_ice_s_dyn(:,:,islope,:)) 125 enddo 126 127 write(*,*) "Downloading data for h2o_ice_s_slope done" 123 128 124 129 #ifndef CPP_STD 125 126 write(*,*) "Downloading data for watercap_slope ..." 127 DO islope=1,nslope 128 write(num,fmt='(i2.2)') islope 129 call get_var3("watercap_slope"//num,watercap_slope(:,:,islope,:)) 130 ! watercap_slope(:,:,:,:)= 0. 131 ENDDO 132 write(*,*) "Downloading data for watercap_slope done" 133 134 #endif 130 write(*,*) "Downloading data for watercap_slope ..." 131 do islope = 1,nslope 132 write(num,'(i2.2)') islope 133 call get_var3("watercap_slope"//num,watercap_slope(:,:,islope,:)) 134 ! watercap_slope(:,:,:,:) = 0. 135 enddo 136 write(*,*) "Downloading data for watercap_slope done" 137 #endif 138 139 write(*,*) "Downloading data for tsurf_slope ..." 140 141 do islope=1,nslope 142 write(num,'(i2.2)') islope 143 call get_var3("tsurf_slope"//num,tsurf_gcm_dyn(:,:,islope,:)) 144 enddo 145 146 write(*,*) "Downloading data for tsurf_slope done" 147 148 #ifndef CPP_STD 149 if (soil_pem) then 150 write(*,*) "Downloading data for soiltemp_slope ..." 151 152 do islope = 1,nslope 153 write(num,'(i2.2)') islope 154 call get_var4("soiltemp_slope"//num,tsoil_gcm_dyn(:,:,:,islope,:)) 155 enddo 156 157 write(*,*) "Downloading data for soiltemp_slope done" 158 write(*,*) "Downloading data for watersoil_density ..." 159 160 do islope = 1,nslope 161 write(num,'(i2.2)') islope 162 call get_var4("Waterdensity_soil_slope"//num,watersoil_density_dyn(:,:,:,islope,:)) 163 enddo 164 165 write(*,*) "Downloading data for watersoil_density done" 166 write(*,*) "Downloading data for watersurf_density ..." 167 168 do islope = 1,nslope 169 write(num,'(i2.2)') islope 170 call get_var3("Waterdensity_surface"//num,watersurf_density_dyn(:,:,islope,:)) 171 enddo 172 173 write(*,*) "Downloading data for watersurf_density done" 174 175 endif !soil_pem 176 #endif 177 else !nslope = 1 no slope, we copy all the values 178 call get_var3("h2o_ice_s", h2o_ice_s_dyn(:,:,1,:)) 179 call get_var3("co2ice", co2_ice_slope_dyn(:,:,1,:)) 180 call get_var3("tsurf", tsurf_gcm_dyn(:,:,1,:)) 135 181 136 write(*,*) "Downloading data for tsurf_slope ..."137 138 DO islope=1,nslope139 write(num,fmt='(i2.2)') islope140 call get_var3("tsurf_slope"//num,tsurf_gcm_dyn(:,:,islope,:))141 ENDDO142 143 write(*,*) "Downloading data for tsurf_slope done"144 145 #ifndef CPP_STD146 147 if(soil_pem) then148 149 write(*,*) "Downloading data for soiltemp_slope ..."150 151 DO islope=1,nslope152 write(num,fmt='(i2.2)') islope153 call get_var4("soiltemp_slope"//num,tsoil_gcm_dyn(:,:,:,islope,:))154 ENDDO155 156 write(*,*) "Downloading data for soiltemp_slope done"157 158 write(*,*) "Downloading data for watersoil_density ..."159 160 DO islope=1,nslope161 write(num,fmt='(i2.2)') islope162 call get_var4("Waterdensity_soil_slope"//num,watersoil_density_dyn(:,:,:,islope,:))163 ENDDO164 165 write(*,*) "Downloading data for watersoil_density done"166 167 write(*,*) "Downloading data for watersurf_density ..."168 169 DO islope=1,nslope170 write(num,fmt='(i2.2)') islope171 call get_var3("Waterdensity_surface"//num,watersurf_density_dyn(:,:,islope,:))172 ENDDO173 174 write(*,*) "Downloading data for watersurf_density done"175 176 endif !soil_pem177 178 #endif179 180 else !nslope=1 no slope, we copy all the values181 182 CALL get_var3("h2o_ice_s", h2o_ice_s_dyn(:,:,1,:))183 CALL get_var3("co2ice", co2_ice_slope_dyn(:,:,1,:))184 call get_var3("tsurf", tsurf_gcm_dyn(:,:,1,:))185 182 #ifndef CPP_STD 186 183 ! call get_var3("watercap", watercap_slope(:,:,1,:)) 187 watercap_slope(:,:,1,:)=0. 188 watersurf_density_dyn(:,:,:,:)=0. 189 watersoil_density_dyn(:,:,:,:,:)=0. 190 #endif 191 192 if(soil_pem) then 193 call get_var4("soiltemp",tsoil_gcm_dyn(:,:,:,1,:)) 184 watercap_slope(:,:,1,:) = 0. 185 watersurf_density_dyn(:,:,:,:) = 0. 186 watersoil_density_dyn(:,:,:,:,:) = 0. 187 #endif 188 189 if (soil_pem) call get_var4("soiltemp",tsoil_gcm_dyn(:,:,:,1,:)) 190 endif !nslope=1 191 192 ! Compute the minimum over the year for each point 193 write(*,*) "Computing the min of h2o_ice_slope" 194 min_h2o_ice_dyn(:,:,:) = minval(h2o_ice_s_dyn + watercap_slope,4) 195 write(*,*) "Computing the min of co2_ice_slope" 196 min_co2_ice_dyn(:,:,:) = minval(co2_ice_slope_dyn,4) 197 198 !Compute averages 199 write(*,*) "Computing average of tsurf" 200 tsurf_ave_dyn(:,:,:) = sum(tsurf_gcm_dyn(:,:,:,:),4)/timelen 201 202 #ifndef CPP_1D 203 do islope = 1,nslope 204 do t = 1,timelen 205 call gr_dyn_fi(1,iim_input+1,jjm_input+1,ngrid,watersurf_density_dyn(:,:,islope,t),watersurf_density(:,islope,t)) 206 enddo 207 enddo 208 #endif 209 210 if (soil_pem) then 211 write(*,*) "Computing average of tsoil" 212 tsoil_ave_dyn(:,:,:,:) = sum(tsoil_gcm_dyn(:,:,:,:,:),5)/timelen 213 write(*,*) "Computing average of watersurf_density" 214 watersurf_density_ave(:,:) = sum(watersurf_density(:,:,:),3)/timelen 215 endif 216 217 ! By definition, a density is positive, we get rid of the negative values 218 where (min_co2_ice_dyn < 0.) min_co2_ice_dyn = 0. 219 where (min_h2o_ice_dyn < 0.) min_h2o_ice_dyn = 0. 220 221 do i = 1,iim + 1 222 do j = 1,jjm_input + 1 223 do t = 1, timelen 224 if (q_co2_dyn(i,j,t) < 0) then 225 q_co2_dyn(i,j,t) = 1.e-10 226 else if (q_co2_dyn(i,j,t) > 1) then 227 q_co2_dyn(i,j,t) = 1. 228 endif 229 if (q_h2o_dyn(i,j,t) < 0) then 230 q_h2o_dyn(i,j,t) = 1.e-30 231 else if (q_h2o_dyn(i,j,t) > 1) then 232 q_h2o_dyn(i,j,t) = 1. 233 endif 234 mmean = 1/(A*q_co2_dyn(i,j,t) + B) 235 vmr_co2_gcm(i,j,t) = q_co2_dyn(i,j,t)*mmean/m_co2 236 enddo 237 enddo 238 enddo 239 240 #ifndef CPP_1D 241 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,vmr_co2_gcm,vmr_co2_gcm_phys) 242 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,ps_GCM,ps_timeseries) 243 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,q_co2_dyn,q_co2) 244 call gr_dyn_fi(timelen,iim_input + 1,jjm_input + 1,ngrid,q_h2o_dyn,q_h2o) 245 246 do islope = 1,nslope 247 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_co2_ice_dyn(:,:,islope),min_co2_ice(:,islope)) 248 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,min_h2o_ice_dyn(:,:,islope),min_h2o_ice(:,islope)) 249 if (soil_pem) then 250 do l = 1,nsoilmx 251 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsoil_ave_dyn(:,:,l,islope),tsoil_ave(:,l,islope)) 252 do t=1,timelen 253 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsoil_gcm_dyn(:,:,l,islope,t),tsoil_gcm(:,l,islope,t)) 254 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,watersoil_density_dyn(:,:,l,islope,t),watersoil_density(:,l,islope,t)) 255 enddo 256 enddo 257 endif !soil_pem 258 do t = 1,timelen 259 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,tsurf_GCM_dyn(:,:,islope,t),tsurf_GCM(:,islope,t)) 260 call gr_dyn_fi(1,iim_input + 1,jjm_input + 1,ngrid,co2_ice_slope_dyn(:,:,islope,t),co2_ice_slope(:,islope,t)) 261 enddo 262 enddo 263 264 call gr_dyn_fi(nslope,iim_input + 1,jjm_input + 1,ngrid,tsurf_ave_dyn,tsurf_ave) 265 #else 266 vmr_co2_gcm_phys(1,:) = vmr_co2_gcm(1,1,:) 267 ps_timeseries(1,:) = ps_GCM(1,1,:) 268 q_co2(1,:) = q_co2_dyn(1,1,:) 269 q_h2o(1,:) = q_h2o_dyn(1,1,:) 270 min_co2_ice(1,:) = min_co2_ice_dyn(1,1,:) 271 min_h2o_ice(1,:) = min_h2o_ice_dyn(1,1,:) 272 if (soil_pem) then 273 tsoil_ave(1,:,:) = tsoil_ave_dyn(1,1,:,:) 274 tsoil_gcm(1,:,:,:) = tsoil_gcm_dyn(1,1,:,:,:) 275 watersoil_density(1,:,:,:) = watersoil_density_dyn(1,1,:,:,:) 194 276 endif !soil_pem 195 endif !nslope=1 196 197 ! Compute the minimum over the year for each point 198 write(*,*) "Computing the min of h2o_ice_slope" 199 min_h2o_ice_dyn(:,:,:)=minval(h2o_ice_s_dyn+watercap_slope,4) 200 write(*,*) "Computing the min of co2_ice_slope" 201 min_co2_ice_dyn(:,:,:)=minval(co2_ice_slope_dyn,4) 202 203 !Compute averages 204 205 write(*,*) "Computing average of tsurf" 206 tsurf_ave_dyn(:,:,:)=SUM(tsurf_gcm_dyn(:,:,:,:),4)/timelen 207 208 #ifndef CPP_1D 209 DO islope = 1,nslope 210 DO t=1,timelen 211 CALL gr_dyn_fi(1,iim_input+1,jjm_input+1,ngrid,watersurf_density_dyn(:,:,islope,t),watersurf_density(:,islope,t)) 212 ENDDO 213 ENDDO 214 #endif 215 216 if(soil_pem) then 217 write(*,*) "Computing average of tsoil" 218 tsoil_ave_dyn(:,:,:,:)=SUM(tsoil_gcm_dyn(:,:,:,:,:),5)/timelen 219 write(*,*) "Computing average of watersurf_density" 220 watersurf_density_ave(:,:) = SUM(watersurf_density(:,:,:),3)/timelen 221 endif 222 223 ! By definition, a density is positive, we get rid of the negative values 224 DO i=1,iim+1 225 DO j = 1, jjm_input+1 226 DO islope=1,nslope 227 if (min_co2_ice_dyn(i,j,islope).LT.0) then 228 min_co2_ice_dyn(i,j,islope) = 0. 229 endif 230 if (min_h2o_ice_dyn(i,j,islope).LT.0) then 231 min_h2o_ice_dyn(i,j,islope) = 0. 232 endif 233 ENDDO 234 ENDDO 235 ENDDO 236 237 DO i=1,iim+1 238 DO j = 1, jjm_input+1 239 DO t = 1, timelen 240 if (q_co2_dyn(i,j,t).LT.0) then 241 q_co2_dyn(i,j,t)=1E-10 242 elseif (q_co2_dyn(i,j,t).GT.1) then 243 q_co2_dyn(i,j,t)=1. 244 endif 245 if (q_h2o_dyn(i,j,t).LT.0) then 246 q_h2o_dyn(i,j,t)=1E-30 247 elseif (q_h2o_dyn(i,j,t).GT.1) then 248 q_h2o_dyn(i,j,t)=1. 249 endif 250 mmean=1/(A*q_co2_dyn(i,j,t) +B) 251 vmr_co2_gcm(i,j,t) = q_co2_dyn(i,j,t)*mmean/m_co2 252 ENDDO 253 ENDDO 254 ENDDO 255 256 #ifndef CPP_1D 257 258 CALL gr_dyn_fi(timelen,iim_input+1,jjm_input+1,ngrid,vmr_co2_gcm,vmr_co2_gcm_phys) 259 call gr_dyn_fi(timelen,iim_input+1,jjm_input+1,ngrid,ps_GCM,ps_timeseries) 260 CALL gr_dyn_fi(timelen,iim_input+1,jjm_input+1,ngrid,q_co2_dyn,q_co2) 261 CALL gr_dyn_fi(timelen,iim_input+1,jjm_input+1,ngrid,q_h2o_dyn,q_h2o) 262 263 DO islope = 1,nslope 264 CALL gr_dyn_fi(1,iim_input+1,jjm_input+1,ngrid,min_co2_ice_dyn(:,:,islope),min_co2_ice(:,islope)) 265 CALL gr_dyn_fi(1,iim_input+1,jjm_input+1,ngrid,min_h2o_ice_dyn(:,:,islope),min_h2o_ice(:,islope)) 266 if(soil_pem) then 267 DO l=1,nsoilmx 268 CALL gr_dyn_fi(1,iim_input+1,jjm_input+1,ngrid,tsoil_ave_dyn(:,:,l,islope),tsoil_ave(:,l,islope)) 269 DO t=1,timelen 270 CALL gr_dyn_fi(1,iim_input+1,jjm_input+1,ngrid,tsoil_gcm_dyn(:,:,l,islope,t),tsoil_gcm(:,l,islope,t)) 271 CALL gr_dyn_fi(1,iim_input+1,jjm_input+1,ngrid,watersoil_density_dyn(:,:,l,islope,t),watersoil_density(:,l,islope,t)) 272 ENDDO 273 ENDDO 274 endif !soil_pem 275 DO t=1,timelen 276 CALL gr_dyn_fi(1,iim_input+1,jjm_input+1,ngrid,tsurf_GCM_dyn(:,:,islope,t),tsurf_GCM(:,islope,t)) 277 CALL gr_dyn_fi(1,iim_input+1,jjm_input+1,ngrid,co2_ice_slope_dyn(:,:,islope,t),co2_ice_slope(:,islope,t)) 278 ENDDO 279 ENDDO 280 281 CALL gr_dyn_fi(nslope,iim_input+1,jjm_input+1,ngrid,tsurf_ave_dyn,tsurf_ave) 282 283 #else 284 285 vmr_co2_gcm_phys(1,:)=vmr_co2_gcm(1,1,:) 286 ps_timeseries(1,:)=ps_GCM(1,1,:) 287 q_co2(1,:)=q_co2_dyn(1,1,:) 288 q_h2o(1,:)=q_h2o_dyn(1,1,:) 289 min_co2_ice(1,:)=min_co2_ice_dyn(1,1,:) 290 min_h2o_ice(1,:)=min_h2o_ice_dyn(1,1,:) 291 if(soil_pem) then 292 tsoil_ave(1,:,:)=tsoil_ave_dyn(1,1,:,:) 293 tsoil_gcm(1,:,:,:)=tsoil_gcm_dyn(1,1,:,:,:) 294 watersoil_density(1,:,:,:)=watersoil_density_dyn(1,1,:,:,:) 295 endif !soil_pem 296 tsurf_GCM(1,:,:)=tsurf_GCM_dyn(1,1,:,:) 297 co2_ice_slope(1,:,:)=co2_ice_slope_dyn(1,1,:,:) 298 tsurf_ave(1,:)=tsurf_ave_dyn(1,1,:) 299 300 #endif 301 302 CONTAINS 277 tsurf_GCM(1,:,:) = tsurf_GCM_dyn(1,1,:,:) 278 co2_ice_slope(1,:,:) = co2_ice_slope_dyn(1,1,:,:) 279 tsurf_ave(1,:) = tsurf_ave_dyn(1,1,:) 280 #endif 281 282 END SUBROUTINE read_data_gcm 303 283 304 284 SUBROUTINE check_dim(n1,n2,str1,str2) 305 INTEGER, INTENT(IN) :: n1, n2 306 CHARACTER(LEN=*), INTENT(IN) :: str1, str2 307 CHARACTER(LEN=256) :: s1, s2 308 IF(n1/=n2) THEN 309 s1='value of '//TRIM(str1)//' =' 310 s2=' read in starting file differs from parametrized '//TRIM(str2)//' =' 311 WRITE(msg,'(10x,a,i4,2x,a,i4)')TRIM(s1),n1,TRIM(s2),n2 312 CALL ABORT_gcm(TRIM(modname),TRIM(msg),1) 313 END IF 285 286 implicit none 287 288 integer, intent(in) :: n1, n2 289 character(len = *), intent(in) :: str1, str2 290 291 character(256) :: s1, s2 292 293 if (n1 /= n2) then 294 s1 = 'value of '//trim(str1)//' =' 295 s2 = ' read in starting file differs from parametrized '//trim(str2)//' =' 296 write(msg,'(10x,a,i4,2x,a,i4)')trim(s1),n1,trim(s2),n2 297 call abort_gcm(trim(modname),trim(msg),1) 298 endif 299 314 300 END SUBROUTINE check_dim 315 301 302 !======================================================================= 316 303 317 304 SUBROUTINE get_var1(var,v) 318 CHARACTER(LEN=*), INTENT(IN) :: var 319 REAL, INTENT(OUT) :: v(:) 320 CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) 321 CALL err(NF90_GET_VAR(fID,vID,v),"get",var) 305 306 implicit none 307 308 character(len = *), intent(in) :: var 309 real, dimension(:), intent(out) :: v 310 311 call error_msg(NF90_INQ_VARID(fID,var,vID),"inq",var) 312 call error_msg(NF90_GET_VAR(fID,vID,v),"get",var) 313 322 314 END SUBROUTINE get_var1 323 315 316 !======================================================================= 324 317 325 318 SUBROUTINE get_var3(var,v) ! on U grid 326 CHARACTER(LEN=*), INTENT(IN) :: var 327 REAL, INTENT(OUT) :: v(:,:,:) 328 CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) 329 CALL err(NF90_GET_VAR(fID,vID,v),"get",var) 319 320 implicit none 321 322 character(len = *), intent(in) :: var 323 real, dimension(:,:,:), intent(out) :: v 324 325 call error_msg(NF90_INQ_VARID(fID,var,vID),"inq",var) 326 call error_msg(NF90_GET_VAR(fID,vID,v),"get",var) 330 327 331 328 END SUBROUTINE get_var3 332 329 333 SUBROUTINE get_var4(var,v) 334 CHARACTER(LEN=*), INTENT(IN) :: var 335 REAL, INTENT(OUT) :: v(:,:,:,:) 336 CALL err(NF90_INQ_VARID(fID,var,vID),"inq",var) 337 CALL err(NF90_GET_VAR(fID,vID,v),"get",var) 330 !======================================================================= 331 332 SUBROUTINE get_var4(var,v) 333 334 implicit none 335 336 character(len = *), intent(in) :: var 337 real, dimension(:,:,:,:), intent(out) :: v 338 339 call error_msg(NF90_INQ_VARID(fID,var,vID),"inq",var) 340 call error_msg(NF90_GET_VAR(fID,vID,v),"get",var) 341 338 342 END SUBROUTINE get_var4 339 343 340 SUBROUTINE err(ierr,typ,nam) 341 INTEGER, INTENT(IN) :: ierr !--- NetCDF ERROR CODE 342 CHARACTER(LEN=*), INTENT(IN) :: typ !--- TYPE OF OPERATION 343 CHARACTER(LEN=*), INTENT(IN) :: nam !--- FIELD/FILE NAME 344 IF(ierr==NF90_NoERR) RETURN 345 SELECT CASE(typ) 346 CASE('inq'); msg="Field <"//TRIM(nam)//"> is missing" 347 CASE('get'); msg="Reading failed for <"//TRIM(nam)//">" 348 CASE('open'); msg="File opening failed for <"//TRIM(nam)//">" 349 CASE('close'); msg="File closing failed for <"//TRIM(nam)//">" 350 END SELECT 351 CALL ABORT_gcm(TRIM(modname),TRIM(msg),ierr) 352 END SUBROUTINE err 353 354 END SUBROUTINE read_data_gcm 344 !======================================================================= 345 346 SUBROUTINE error_msg(ierr,typ,nam) 347 348 implicit none 349 350 integer, intent(in) :: ierr !--- NetCDF ERROR CODE 351 character(len = *), intent(in) :: typ !--- TYPE OF OPERATION 352 character(len = *), intent(in) :: nam !--- FIELD/FILE NAME 353 354 if (ierr == nf90_noerr) return 355 select case(typ) 356 case('inq'); msg="Field <"//trim(nam)//"> is missing" 357 case('get'); msg="Reading failed for <"//trim(nam)//">" 358 case('open'); msg="File opening failed for <"//trim(nam)//">" 359 case('close'); msg="File closing failed for <"//trim(nam)//">" 360 case default 361 write(*,*) 'There is no message for this error.' 362 error stop 363 end select 364 call abort_gcm(trim(modname),trim(msg),ierr) 365 366 END SUBROUTINE error_msg 367 368 END MODULE read_data_GCM_mod -
trunk/LMDZ.COMMON/libf/evolution/recomp_orb_param_mod.F90
r3069 r3076 6 6 ! Author: RV, JBC 7 7 !======================================================================= 8 IMPLICIT NONE9 8 10 CONTAINS 9 implicit none 10 11 !======================================================================= 12 contains 13 !======================================================================= 11 14 12 15 SUBROUTINE recomp_orb_param(i_myear,year_iter) 13 16 14 use time_evol_mod, only: year_bp_ini, var_obl, var_ecc, var_lsp, convert_years 15 #ifndef CPP_STD 17 use time_evol_mod, only: year_bp_ini, var_obl, var_ecc, var_lsp, convert_years 18 use lask_param_mod, only: yearlask, obllask, ecclask, lsplask, end_lask_param_mod, last_ilask 19 #ifndef CPP_STD 16 20 use comconst_mod, only: pi 17 21 use planete_h, only: e_elips, obliquit, lsperi, periheli, aphelie, p_elips, peri_day, year_day … … 21 25 #endif 22 26 23 use lask_param_mod, only: yearlask, obllask, ecclask, lsplask, end_lask_param_mod, last_ilask 24 25 IMPLICIT NONE 27 implicit none 26 28 27 29 !-------------------------------------------------------- 28 30 ! Input Variables 29 31 !-------------------------------------------------------- 30 31 32 integer, intent(in) :: i_myear ! Number of simulated Martian years 33 integer, intent(in) :: year_iter ! Number of iterations of the PEM 32 34 33 35 !-------------------------------------------------------- … … 36 38 37 39 !-------------------------------------------------------- 38 ! Local variables 40 ! Local variables 39 41 !-------------------------------------------------------- 40 41 42 43 44 45 46 42 integer :: Year ! Year of the simulation 43 real :: Lsp ! Ls perihelion 44 integer :: ilask ! Loop variable 45 real :: halfaxe ! Million of km 46 real :: unitastr 47 real :: xa, xb, ya, yb ! Variables for interpolation 48 logical :: found_year ! Flag variable 47 49 48 50 ! ********************************************************************** 49 51 ! 0. Initializations 50 52 ! ********************************************************************** 51 #ifdef CPP_STD 52 real aphelie 53 real periheli 53 #ifdef CPP_STD 54 real :: aphelie, periheli 54 55 55 aphelie =apoastr56 periheli =periastr56 aphelie = apoastr 57 periheli = periastr 57 58 #endif 58 59 … … 111 112 p_elips = 0.5*(periheli + aphelie)*(1. - e_elips*e_elips)/unitastr 112 113 113 #ifndef CPP_STD 114 #ifndef CPP_STD 114 115 call call_dayperi(Lsp,e_elips,peri_day,year_day) 115 116 #endif … … 122 123 END SUBROUTINE recomp_orb_param 123 124 124 !******************************************************************************** 125 125 !******************************************************************************** 126 126 127 END MODULE recomp_orb_param_mod 127 128 -
trunk/LMDZ.COMMON/libf/evolution/recomp_tend_co2_slope_mod.F90
r3075 r3076 1 ! 2 ! $Id $ 3 ! 4 SUBROUTINE recomp_tend_co2_slope(ngrid,nslope,timelen,tendencies_co2_ice_phys,tendencies_co2_ice_phys_ini,co2ice_slope, emissivity_slope, & 1 MODULE recomp_tend_co2_slope_mod 2 3 implicit none 4 5 !======================================================================= 6 contains 7 !======================================================================= 8 9 SUBROUTINE recomp_tend_co2_slope(ngrid,nslope,timelen,tendencies_co2_ice_phys,tendencies_co2_ice_phys_ini,co2ice_slope,emissivity_slope, & 5 10 vmr_co2_gcm,vmr_co2_pem,ps_GCM_2,global_ave_press_GCM,global_ave_press_new) 6 11 7 12 use constants_marspem_mod, only : alpha_clap_co2, beta_clap_co2, sigmaB,Lco2, sols_per_my, sec_per_sol 8 13 9 IMPLICIT NONE 14 implicit none 10 15 11 16 !======================================================================= … … 17 22 ! arguments: 18 23 ! ---------- 19 20 24 ! INPUT 21 INTEGER, intent(in) :: timelen,ngrid,nslope 22 REAL, INTENT(in) :: vmr_co2_gcm(ngrid,timelen) ! physical point field : Volume mixing ratio of co2 in the first layer 23 REAL, INTENT(in) :: vmr_co2_pem(ngrid,timelen) ! physical point field : Volume mixing ratio of co2 in the first layer 24 REAL, intent(in) :: ps_GCM_2(ngrid,timelen) ! physical point field : Surface pressure in the GCM 25 REAL, intent(in) :: global_ave_press_GCM ! global averaged pressure at previous timestep 26 REAL, intent(in) :: global_ave_press_new ! global averaged pressure at current timestep 27 REAL, intent(in) :: tendencies_co2_ice_phys_ini(ngrid,nslope) ! physical point field : Evolution of perenial ice over one year 28 REAL, intent(in) :: co2ice_slope(ngrid,nslope) ! CO2 ice per mesh and sub-grid slope(kg/m^2) 29 REAL, intent(in) :: emissivity_slope(ngrid,nslope) ! Emissivity per mesh and sub-grid slope(1) 30 25 integer, intent(in) :: timelen, ngrid, nslope 26 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_gcm ! physical point field : Volume mixing ratio of co2 in the first layer 27 real, dimension(ngrid,timelen), intent(in) :: vmr_co2_pem ! physical point field : Volume mixing ratio of co2 in the first layer 28 real, dimension(ngrid,timelen), intent(in) :: ps_GCM_2 ! physical point field : Surface pressure in the GCM 29 real, intent(in) :: global_ave_press_GCM ! global averaged pressure at previous timestep 30 real, intent(in) :: global_ave_press_new ! global averaged pressure at current timestep 31 real, dimension(ngrid,nslope), intent(in) :: tendencies_co2_ice_phys_ini ! physical point field : Evolution of perenial ice over one year 32 real, dimension(ngrid,nslope), intent(in) :: co2ice_slope ! CO2 ice per mesh and sub-grid slope(kg/m^2) 33 real, dimension(ngrid,nslope), intent(in) :: emissivity_slope ! Emissivity per mesh and sub-grid slope(1) 31 34 ! OUTPUT 32 REAL, intent(inout) :: tendencies_co2_ice_phys(ngrid,nslope) ! physical point field : Evolution of perenial ice over one year35 real, intent(inout) :: tendencies_co2_ice_phys(ngrid,nslope) ! physical point field : Evolution of perenial ice over one year 33 36 34 37 ! local: 35 38 ! ---- 36 37 INTEGER :: i,t,islope 38 REAL :: coef, ave 39 integer :: i, t, islope 40 real :: coef, ave 39 41 40 42 ! Evolution of the water ice for each physical point 41 do i=1,ngrid42 do islope =1,nslope43 coef=sols_per_my*sec_per_sol*emissivity_slope(i,islope)*sigmaB/Lco244 ave=0.45 if(co2ice_slope(i,islope).gt.1e-4 .and. abs(tendencies_co2_ice_phys(i,islope)).gt.1e-5) then46 do t=1,timelen47 ave=ave+(beta_clap_co2/(alpha_clap_co2-log(vmr_co2_gcm(i,t)*ps_GCM_2(i,t)/100.)))**4&48 -(beta_clap_co2/(alpha_clap_co2-log(vmr_co2_pem(i,t)*ps_GCM_2(i,t)*(global_ave_press_new/global_ave_press_GCM)/100.)))**449 enddo50 endif51 if(ave.lt.1e-4) ave = 0.52 tendencies_co2_ice_phys(i,islope)=tendencies_co2_ice_phys_ini(i,islope)-coef*ave/timelen43 do i = 1,ngrid 44 do islope = 1,nslope 45 coef = sols_per_my*sec_per_sol*emissivity_slope(i,islope)*sigmaB/Lco2 46 ave = 0. 47 if (co2ice_slope(i,islope) > 1.e-4 .and. abs(tendencies_co2_ice_phys(i,islope)) > 1.e-5) then 48 do t=1,timelen 49 ave = ave + (beta_clap_co2/(alpha_clap_co2-log(vmr_co2_gcm(i,t)*ps_GCM_2(i,t)/100.)))**4 & 50 - (beta_clap_co2/(alpha_clap_co2-log(vmr_co2_pem(i,t)*ps_GCM_2(i,t)*(global_ave_press_new/global_ave_press_GCM)/100.)))**4 51 enddo 52 endif 53 if (ave < 1e-4) ave = 0. 54 tendencies_co2_ice_phys(i,islope) = tendencies_co2_ice_phys_ini(i,islope) - coef*ave/timelen 53 55 enddo 54 56 enddo 55 57 56 58 END SUBROUTINE recomp_tend_co2_slope 59 60 END MODULE recomp_tend_co2_slope_mod -
trunk/LMDZ.COMMON/libf/evolution/reshape_XIOS_output.F90
r3050 r3076 1 programreshape_XIOS_output1 PROGRAM reshape_XIOS_output 2 2 3 3 !======================================================================= … … 10 10 ! Authors: RV & LL 11 11 !======================================================================= 12 use netcdf 13 implicit none 14 integer :: status, ncid, ncid1, ncid2 15 integer :: nDims, nVars, nGlobalAtts, unlimDimID 16 integer i,j 17 18 integer :: include_parents 19 20 integer, dimension(:),allocatable :: dimids 21 integer, dimension(:),allocatable :: varids 22 23 integer, dimension(:),allocatable :: dimids_2 24 integer, dimension(:),allocatable :: varids_2 25 26 integer, dimension(:),allocatable :: dimid_var 27 28 real, dimension(:), allocatable :: tempvalues_1d 29 real, dimension(:), allocatable :: values_1d 30 31 real, dimension(:,:), allocatable :: tempvalues_2d 32 real, dimension(:,:), allocatable :: values_2d 33 34 real, dimension(:,:,:), allocatable :: tempvalues_3d 35 real, dimension(:,:,:), allocatable :: values_3d 36 37 real, dimension(:,:,:,:), allocatable :: tempvalues_4d 38 real, dimension(:,:,:,:), allocatable :: values_4d 39 40 character*1 str2 41 character*30 :: name_ 42 character*30 :: namevar 43 integer :: xtype_var 44 integer :: len_ 45 integer :: len_1,len_2 46 integer :: len_lat, len_lon, len_time, len_soil 47 integer :: dimid_lon, dimid_lat, dimid_time, dimid_soil 48 integer :: dimid_2 49 integer :: numdims 50 integer :: numatts 51 integer :: numyear 52 53 DO numyear=1, 2 54 write(*,*) 'numyear',numyear 55 write(str2(1:1),'(i1.1)') numyear 56 !nf90_open ! open existing netCDF dataset 57 !integer :: ncid, status 58 !... 59 status = nf90_open(path = "data2reshape"//str2//".nc", mode = nf90_nowrite, ncid = ncid1) 60 if(status /= nf90_noerr) call handle_err(status) 61 62 status = nf90_create(path = "datareshaped"//str2//".nc", cmode=or(nf90_noclobber,nf90_64bit_offset), ncid = ncid2) 63 if(status /= nf90_noerr) call handle_err(status) 64 65 status = nf90_inquire(ncid1, ndims, nvars, nglobalatts, unlimdimid) 66 if(status /= nf90_noerr) call handle_err(status) 67 68 allocate(dimids(ndims)) 69 allocate(varids(nvars)) 70 71 allocate(dimids_2(ndims)) 72 allocate(varids_2(nvars)) 73 74 status = nf90_inq_dimids(ncid1, ndims, dimids, include_parents) 75 if(status /= nf90_noerr) call handle_err(status) 76 status = nf90_inq_varids(ncid1, nvars, varids) 77 if(status /= nf90_noerr) call handle_err(status) 78 79 do i=1,ndims 80 status = nf90_inquire_dimension(ncid1, dimids(i), name_, len_) 81 if(status /= nf90_noerr) call handle_err(status) 82 if(name_.eq."lon" .or. name_.eq."longitude") then 83 dimid_lon=dimids(i) 84 len_lon=len_ 85 len_=len_+1 86 elseif(name_.eq."lat".or. name_.eq."latitude") then 87 dimid_lat=dimids(i) 88 len_lat=len_ 89 elseif(name_.eq."time_counter".or. name_.eq. "Time") then 90 dimid_time=dimids(i) 91 len_time=len_ 92 elseif(name_.eq."soil_layers".or. name_.eq. "subsurface_layers") then 93 dimid_soil=dimids(i) 94 len_soil=len_ 95 endif 96 status = nf90_def_dim(ncid2, name_, len_, dimid_2) 97 if(status /= nf90_noerr) call handle_err(status) 98 dimids_2(i)=dimid_2 12 use netcdf 13 14 implicit none 15 16 integer :: state, ncid, ncid1, ncid2, nDims, nVars, nGlobalAtts, unlimDimID 17 integer :: i, j, include_parents 18 integer, dimension(:), allocatable :: dimids, varids, dimids_2, varids_2, dimid_var 19 real, dimension(:), allocatable :: tempvalues_1d, values_1d 20 real, dimension(:,:), allocatable :: tempvalues_2d, values_2d 21 real, dimension(:,:,:), allocatable :: tempvalues_3d, values_3d 22 real, dimension(:,:,:,:), allocatable :: tempvalues_4d, values_4d 23 character(1) :: str2 24 character(30) :: name_, namevar 25 integer :: xtype_var, len_, len_1, len_2, len_lat, len_lon, len_time, len_soil 26 integer :: dimid_lon, dimid_lat, dimid_time, dimid_soil, dimid_2, numdims, numatts, numyear 27 28 do numyear = 1,2 29 write(*,*) 'numyear',numyear 30 write(str2(1:1),'(i1.1)') numyear 31 !nf90_open ! open existing netCDF dataset 32 !integer :: ncid, state 33 !... 34 state = nf90_open(path = "data2reshape"//str2//".nc", mode = nf90_nowrite, ncid = ncid1) 35 if (state /= nf90_noerr) call handle_err(state) 36 37 state = nf90_create(path = "datareshaped"//str2//".nc", cmode=or(nf90_noclobber,nf90_64bit_offset), ncid = ncid2) 38 if (state /= nf90_noerr) call handle_err(state) 39 40 state = nf90_inquire(ncid1, ndims, nvars, nglobalatts, unlimdimid) 41 if (state /= nf90_noerr) call handle_err(state) 42 43 allocate(dimids(ndims)) 44 allocate(varids(nvars)) 45 46 allocate(dimids_2(ndims)) 47 allocate(varids_2(nvars)) 48 49 state = nf90_inq_dimids(ncid1, ndims, dimids, include_parents) 50 if (state /= nf90_noerr) call handle_err(state) 51 state = nf90_inq_varids(ncid1, nvars, varids) 52 if (state /= nf90_noerr) call handle_err(state) 53 54 do i = 1,ndims 55 state = nf90_inquire_dimension(ncid1, dimids(i), name_, len_) 56 if (state /= nf90_noerr) call handle_err(state) 57 if (name_ == "lon" .or. name_ == "longitude") then 58 dimid_lon = dimids(i) 59 len_lon = len_ 60 len_ = len_ + 1 61 elseif (name_ == "lat".or. name_ == "latitude") then 62 dimid_lat=dimids(i) 63 len_lat=len_ 64 elseif (name_ == "time_counter".or. name_ == "Time") then 65 dimid_time=dimids(i) 66 len_time=len_ 67 elseif (name_ == "soil_layers".or. name_ == "subsurface_layers") then 68 dimid_soil=dimids(i) 69 len_soil = len_ 70 endif 71 state = nf90_def_dim(ncid2, name_,len_,dimid_2) 72 if (state /= nf90_noerr) call handle_err(state) 73 dimids_2(i) = dimid_2 74 enddo 75 76 do i = 1,nvars 77 state = nf90_inquire_variable(ncid1, varids(i),name = namevar,xtype = xtype_var,ndims = numdims,natts = numatts) 78 write(*,*) "namevar00= ", namevar 79 if (state /= nf90_noerr) call handle_err(state) 80 allocate(dimid_var(numdims)) 81 state = nf90_inquire_variable(ncid1,varids(i),name = namevar,xtype = xtype_var,ndims = numdims,dimids = dimid_var,natts = numatts) 82 if (state /= nf90_noerr) call handle_err(state) 83 if (numdims == 1) then 84 if (namevar == "lon") then 85 allocate(tempvalues_1d(len_lon)) 86 allocate(values_1d(len_lon + 1)) 87 state = nf90_get_var(ncid1,varids(i),tempvalues_1d) 88 if (state /= nf90_noerr) call handle_err(state) 89 state = nf90_def_var(ncid2,namevar,xtype_var, dimid_var, varids_2(i)) 90 if (state /= nf90_noerr) call handle_err(state) 91 values_1d(1:len_lon) = tempvalues_1d(:) 92 values_1d(len_lon + 1) = values_1d(1) 93 state = nf90_enddef(ncid2) 94 if (state /= nf90_noerr) call handle_err(state) 95 state = nf90_put_var(ncid2, varids_2(i), values_1d) 96 if (state /= nf90_noerr) call handle_err(state) 97 state = nf90_redef(ncid2) 98 if (state /= nf90_noerr) call handle_err(state) 99 deallocate(tempvalues_1d) 100 deallocate(values_1d) 101 else 102 state = nf90_inquire_dimension(ncid1,dimid_var(1),name_,len_) 103 if (state /= nf90_noerr) call handle_err(state) 104 allocate(tempvalues_1d(len_)) 105 state = nf90_get_var(ncid1,varids(i),tempvalues_1d) 106 if (state /= nf90_noerr) call handle_err(state) 107 state = nf90_def_var(ncid2,namevar,xtype_var,dimid_var,varids_2(i)) 108 if (state /= nf90_noerr) call handle_err(state) 109 state = nf90_enddef(ncid2) 110 if (state /= nf90_noerr) call handle_err(state) 111 state = nf90_put_var(ncid2, varids_2(i), tempvalues_1d) 112 if (state /= nf90_noerr) call handle_err(state) 113 state = nf90_redef(ncid2) 114 if (state /= nf90_noerr) call handle_err(state) 115 deallocate(tempvalues_1d) 116 endif 117 else if (numdims == 2) then 118 if (namevar == "area") then 119 allocate(tempvalues_2d(len_lon,len_lat)) 120 allocate(values_2d(len_lon + 1,len_lat)) 121 state = nf90_get_var(ncid1,varids(i),tempvalues_2d) 122 if (state /= nf90_noerr) call handle_err(state) 123 state = nf90_def_var(ncid2,namevar,xtype_var,dimid_var,varids_2(i)) 124 if (state /= nf90_noerr) call handle_err(state) 125 values_2d(1:len_lon,:) = tempvalues_2d(:,:) 126 values_2d(len_lon+1,:) = values_2d(1,:) 127 state = nf90_enddef(ncid2) 128 if (state /= nf90_noerr) call handle_err(state) 129 state = nf90_put_var(ncid2,varids_2(i),values_2d) 130 if (state /= nf90_noerr) call handle_err(state) 131 state = nf90_redef(ncid2) 132 if (state /= nf90_noerr) call handle_err(state) 133 deallocate(tempvalues_2d) 134 deallocate(values_2d) 135 else 136 state = nf90_inquire_dimension(ncid1,dimid_var(1),name_,len_1) 137 if (state /= nf90_noerr) call handle_err(state) 138 state = nf90_inquire_dimension(ncid1,dimid_var(2),name_,len_2) 139 if (state /= nf90_noerr) call handle_err(state) 140 allocate(tempvalues_2d(len_1,len_2)) 141 state = nf90_get_var(ncid1, varids(i), tempvalues_2d) 142 if (state /= nf90_noerr) call handle_err(state) 143 state = nf90_def_var(ncid2,namevar,xtype_var,dimid_var,varids_2(i)) 144 if (state /= nf90_noerr) call handle_err(state) 145 state = nf90_enddef(ncid2) 146 if (state /= nf90_noerr) call handle_err(state) 147 state = nf90_put_var(ncid2, varids_2(i), tempvalues_2d) 148 if (state /= nf90_noerr) call handle_err(state) 149 state = nf90_redef(ncid2) 150 if (state /= nf90_noerr) call handle_err(state) 151 deallocate(tempvalues_2d) 152 endif 153 elseif (numdims == 3) then 154 allocate(tempvalues_3d(len_lon,len_lat,len_time)) 155 allocate(values_3d(len_lon + 1,len_lat,len_time)) 156 state = nf90_get_var(ncid1,varids(i),tempvalues_3d) 157 if (state /= nf90_noerr) call handle_err(state) 158 state = nf90_def_var(ncid2,namevar,xtype_var,dimid_var,varids_2(i)) 159 if (state /= nf90_noerr) call handle_err(state) 160 values_3d(1:len_lon,:,:) = tempvalues_3d(:,:,:) 161 values_3d(len_lon+1,:,:) = values_3d(1,:,:) 162 state = nf90_enddef(ncid2) 163 if (state /= nf90_noerr) call handle_err(state) 164 state = nf90_put_var(ncid2, varids_2(i), values_3d) 165 if (state /= nf90_noerr) call handle_err(state) 166 state = nf90_redef(ncid2) 167 if (state /= nf90_noerr) call handle_err(state) 168 deallocate(tempvalues_3d) 169 deallocate(values_3d) 170 else if (numdims == 4) then 171 allocate(tempvalues_4d(len_lon,len_lat,len_soil,len_time)) 172 allocate(values_4d(len_lon+1,len_lat,len_soil,len_time)) 173 state = nf90_get_var(ncid1, varids(i), tempvalues_4d) 174 if (state /= nf90_noerr) call handle_err(state) 175 state = nf90_def_var(ncid2, namevar, xtype_var, dimid_var, varids_2(i)) 176 if (state /= nf90_noerr) call handle_err(state) 177 state = nf90_enddef(ncid2) 178 values_4d(1:len_lon,:,:,:) = tempvalues_4d(:,:,:,:) 179 values_4d(len_lon+1,:,:,:) = values_4d(1,:,:,:) 180 if (state /= nf90_noerr) call handle_err(state) 181 state = nf90_put_var(ncid2, varids_2(i), values_4d) 182 if (state /= nf90_noerr) call handle_err(state) 183 state = nf90_redef(ncid2) 184 if (state /= nf90_noerr) call handle_err(state) 185 deallocate(tempvalues_4d) 186 deallocate(values_4d) 187 endif 188 deallocate(dimid_var) 189 enddo 190 191 state = nf90_enddef(ncid2) 192 if (state /= nf90_noerr) call handle_err(state) 193 state = nf90_close(ncid1) 194 if (state /= nf90_noerr) call handle_err(state) 195 state = nf90_close(ncid2) 196 if (state /= nf90_noerr) call handle_err(state) 197 198 deallocate(dimids,varids,dimids_2,varids_2) 99 199 enddo 100 200 101 do i=1,nvars 102 status = nf90_inquire_variable(ncid1, varids(i), name=namevar, xtype=xtype_var, ndims = numdims,natts = numatts) 103 write(*,*) "namevar00= ", namevar 104 if(status /= nf90_noerr) call handle_err(status) 105 allocate(dimid_var(numdims)) 106 status = nf90_inquire_variable(ncid1, varids(i), name=namevar, xtype=xtype_var, ndims = numdims, dimids=dimid_var, natts = numatts) 107 if(status /= nf90_noerr) call handle_err(status) 108 if(numdims.eq.1) then 109 if(namevar.eq."lon") then 110 allocate(tempvalues_1d(len_lon)) 111 allocate(values_1d(len_lon+1)) 112 status = nf90_get_var(ncid1, varids(i), tempvalues_1d) 113 if(status /= nf90_noerr) call handle_err(status) 114 status = nf90_def_var(ncid2, namevar, xtype_var, dimid_var, varids_2(i)) 115 if(status /= nf90_noerr) call handle_err(status) 116 values_1d(1:len_lon)=tempvalues_1d(:) 117 values_1d(len_lon+1)=values_1d(1) 118 status = nf90_enddef(ncid2) 119 if(status /= nf90_noerr) call handle_err(status) 120 status = nf90_put_var(ncid2, varids_2(i), values_1d) 121 if(status /= nf90_noerr) call handle_err(status) 122 status = nf90_redef(ncid2) 123 if(status /= nf90_noerr) call handle_err(status) 124 deallocate(tempvalues_1d) 125 deallocate(values_1d) 126 else 127 status = nf90_inquire_dimension(ncid1, dimid_var(1), name_, len_) 128 if(status /= nf90_noerr) call handle_err(status) 129 allocate(tempvalues_1d(len_)) 130 status = nf90_get_var(ncid1, varids(i), tempvalues_1d) 131 if(status /= nf90_noerr) call handle_err(status) 132 status = nf90_def_var(ncid2, namevar, xtype_var, dimid_var, varids_2(i)) 133 if(status /= nf90_noerr) call handle_err(status) 134 status = nf90_enddef(ncid2) 135 if(status /= nf90_noerr) call handle_err(status) 136 status = nf90_put_var(ncid2, varids_2(i), tempvalues_1d) 137 if(status /= nf90_noerr) call handle_err(status) 138 status = nf90_redef(ncid2) 139 if(status /= nf90_noerr) call handle_err(status) 140 deallocate(tempvalues_1d) 141 endif 142 elseif(numdims.eq.2) then 143 if(namevar.eq."area") then 144 allocate(tempvalues_2d(len_lon,len_lat)) 145 allocate(values_2d(len_lon+1,len_lat)) 146 status = nf90_get_var(ncid1, varids(i), tempvalues_2d) 147 if(status /= nf90_noerr) call handle_err(status) 148 status = nf90_def_var(ncid2, namevar, xtype_var, dimid_var, varids_2(i)) 149 if(status /= nf90_noerr) call handle_err(status) 150 values_2d(1:len_lon,:)=tempvalues_2d(:,:) 151 values_2d(len_lon+1,:)=values_2d(1,:) 152 status = nf90_enddef(ncid2) 153 if(status /= nf90_noerr) call handle_err(status) 154 status = nf90_put_var(ncid2, varids_2(i), values_2d) 155 if(status /= nf90_noerr) call handle_err(status) 156 status = nf90_redef(ncid2) 157 if(status /= nf90_noerr) call handle_err(status) 158 deallocate(tempvalues_2d) 159 deallocate(values_2d) 160 else 161 status = nf90_inquire_dimension(ncid1, dimid_var(1), name_, len_1) 162 if(status /= nf90_noerr) call handle_err(status) 163 status = nf90_inquire_dimension(ncid1, dimid_var(2), name_, len_2) 164 if(status /= nf90_noerr) call handle_err(status) 165 allocate(tempvalues_2d(len_1,len_2)) 166 status = nf90_get_var(ncid1, varids(i), tempvalues_2d) 167 if(status /= nf90_noerr) call handle_err(status) 168 status = nf90_def_var(ncid2, namevar, xtype_var, dimid_var, varids_2(i)) 169 if(status /= nf90_noerr) call handle_err(status) 170 status = nf90_enddef(ncid2) 171 if(status /= nf90_noerr) call handle_err(status) 172 status = nf90_put_var(ncid2, varids_2(i), tempvalues_2d) 173 if(status /= nf90_noerr) call handle_err(status) 174 status = nf90_redef(ncid2) 175 if(status /= nf90_noerr) call handle_err(status) 176 deallocate(tempvalues_2d) 177 endif 178 elseif(numdims.eq.3) then 179 allocate(tempvalues_3d(len_lon,len_lat,len_time)) 180 allocate(values_3d(len_lon+1,len_lat,len_time)) 181 status = nf90_get_var(ncid1, varids(i), tempvalues_3d) 182 if(status /= nf90_noerr) call handle_err(status) 183 status = nf90_def_var(ncid2, namevar, xtype_var, dimid_var, varids_2(i)) 184 if(status /= nf90_noerr) call handle_err(status) 185 values_3d(1:len_lon,:,:)=tempvalues_3d(:,:,:) 186 values_3d(len_lon+1,:,:)=values_3d(1,:,:) 187 status = nf90_enddef(ncid2) 188 if(status /= nf90_noerr) call handle_err(status) 189 status = nf90_put_var(ncid2, varids_2(i), values_3d) 190 if(status /= nf90_noerr) call handle_err(status) 191 status = nf90_redef(ncid2) 192 if(status /= nf90_noerr) call handle_err(status) 193 deallocate(tempvalues_3d) 194 deallocate(values_3d) 195 elseif(numdims.eq.4) then 196 allocate(tempvalues_4d(len_lon,len_lat,len_soil,len_time)) 197 allocate(values_4d(len_lon+1,len_lat,len_soil,len_time)) 198 status = nf90_get_var(ncid1, varids(i), tempvalues_4d) 199 if(status /= nf90_noerr) call handle_err(status) 200 status = nf90_def_var(ncid2, namevar, xtype_var, dimid_var, varids_2(i)) 201 if(status /= nf90_noerr) call handle_err(status) 202 status = nf90_enddef(ncid2) 203 values_4d(1:len_lon,:,:,:)=tempvalues_4d(:,:,:,:) 204 values_4d(len_lon+1,:,:,:)=values_4d(1,:,:,:) 205 if(status /= nf90_noerr) call handle_err(status) 206 status = nf90_put_var(ncid2, varids_2(i), values_4d) 207 if(status /= nf90_noerr) call handle_err(status) 208 status = nf90_redef(ncid2) 209 if(status /= nf90_noerr) call handle_err(status) 210 deallocate(tempvalues_4d) 211 deallocate(values_4d) 212 endif 213 214 deallocate(dimid_var) 215 enddo 216 217 status = nf90_enddef(ncid2) 218 if(status /= nf90_noerr) call handle_err(status) 219 status = nf90_close(ncid1) 220 if(status /= nf90_noerr) call handle_err(status) 221 status = nf90_close(ncid2) 222 if(status /= nf90_noerr) call handle_err(status) 223 224 225 deallocate(dimids) 226 deallocate(varids) 227 deallocate(dimids_2) 228 deallocate(varids_2) 229 230 enddo 231 232 end program reshape_XIOS_output 233 201 END PROGRAM reshape_XIOS_output 202 -
trunk/LMDZ.COMMON/libf/evolution/soil_TIfeedback_PEM_mod.F90
r3075 r3076 1 SUBROUTINE soil_TIfeedback_PEM(ngrid,nsoil,icecover, newtherm_i) 1 MODULE soil_TIfeedback_PEM_mod 2 2 3 use comsoil_h_PEM, only: layer_PEM, inertiedat_PEM 3 implicit none 4 4 5 IMPLICIT NONE 5 !======================================================================= 6 contains 7 !======================================================================= 8 9 SUBROUTINE soil_TIfeedback_PEM(ngrid,nsoil,icecover,newtherm_i) 10 11 use comsoil_h_PEM, only: layer_PEM, inertiedat_PEM 12 13 implicit none 6 14 7 15 !======================================================================= … … 13 21 ! - One layer of surface water ice (the thickness is given 14 22 ! by the variable icecover (in kg of ice per m2) and the thermal 15 ! inertia is prescribed by inert_h2o_ice (see surfdat_h)); 23 ! inertia is prescribed by inert_h2o_ice (see surfdat_h)); 16 24 ! - A transitional layer of mixed thermal inertia; 17 25 ! - A last layer of regolith below the ice cover whose thermal inertia … … 24 32 !======================================================================= 25 33 34 !Inputs 35 !------ 36 integer, intent(in) :: ngrid ! Number of horizontal grid points 37 integer, intent(in) :: nsoil ! Number of soil layers 38 real, dimension(ngrid), intent(in) :: icecover ! tracer on the surface (kg.m-2) 39 !Outputs 40 !------- 41 real,intent(inout) :: newtherm_i(ngrid,nsoil) ! New soil thermal inertia 26 42 !Local variables 27 43 !--------------- 44 integer :: ig ! Grid point (ngrid) 45 integer :: ik ! Grid point (nsoil) 46 integer :: iref ! Ice/Regolith boundary index 47 real :: icedepth ! Ice cover thickness (m) 48 real :: inert_h2o_ice = 800. ! surface water ice thermal inertia [SI] 49 real :: rho_ice = 920. ! density of water ice [kg/m^3] 50 real :: prev_thermi(ngrid,nsoil) ! previous thermal inertia [SI] 28 51 29 INTEGER :: ig ! Grid point (ngrid) 30 INTEGER :: ik ! Grid point (nsoil) 31 INTEGER :: iref ! Ice/Regolith boundary index 32 INTEGER, INTENT(IN) :: ngrid ! Number of horizontal grid points 33 INTEGER, INTENT(IN) :: nsoil ! Number of soil layers 34 REAL :: icedepth ! Ice cover thickness (m) 35 REAL :: inert_h2o_ice = 800. ! surface water ice thermal inertia [SI] 36 REAL :: rho_ice = 920. ! density of water ice [kg/m^3] 37 REAL :: prev_thermi(ngrid,nsoil) ! previous thermal inertia [SI] 38 !Inputs 39 !------ 40 41 REAL ,INTENT(IN):: icecover(ngrid) ! tracer on the surface (kg.m-2) 42 43 !Outputs 44 !------- 45 46 REAL,INTENT(INOUT) :: newtherm_i(ngrid,nsoil) ! New soil thermal inertia 47 48 prev_thermi(:,:) = newtherm_i(:,:) 52 prev_thermi(:,:) = newtherm_i(:,:) 49 53 50 54 !Creating the new soil thermal inertia table 51 55 !------------------------------------------- 52 DO ig=1,ngrid 53 ! Calculating the ice cover thickness 54 55 icedepth=icecover(ig)/rho_ice 56 57 ! If the ice cover is too thick or watercaptag=true, 58 ! the entire column is changed : 59 IF (icedepth.ge.layer_PEM(nsoil)) THEN 60 DO ik=1,nsoil 61 newtherm_i(ig,ik)=max(inert_h2o_ice,prev_thermi(ig,ik)) 62 ENDDO 63 ! We neglect the effect of a very thin ice cover : 64 ELSE IF (icedepth.lt.layer_PEM(1)) THEN 65 DO ik=1,nsoil 66 newtherm_i(ig,ik)=inertiedat_PEM(ig,ik) 67 ENDDO 68 ELSE 69 ! Ice/regolith boundary index : 70 iref=1 71 ! Otherwise, we find the ice/regolith boundary: 72 DO ik=1,nsoil-1 73 IF ((icedepth.ge.layer_PEM(ik)).and. (icedepth.lt.layer_PEM(ik+1))) THEN 74 iref=ik+1 75 EXIT 76 ENDIF 77 ENDDO 78 ! And we change the thermal inertia: 79 DO ik=1,iref-1 80 newtherm_i(ig,ik)=max(inert_h2o_ice,prev_thermi(ig,ik)) 81 ENDDO 82 ! Transition (based on the equations of thermal conduction): 83 newtherm_i(ig,iref)=sqrt( (layer_PEM(iref)-layer_PEM(iref-1)) / & 84 ( ((icedepth-layer_PEM(iref-1))/newtherm_i(ig,iref-1)**2) + & 85 ((layer_PEM(iref)-icedepth)/inertiedat_PEM(ig,ik)**2) ) ) 86 ! Underlying regolith: 87 DO ik=iref+1,nsoil 88 newtherm_i(ig,ik)=inertiedat_PEM(ig,ik) 89 ENDDO 90 ENDIF ! icedepth 91 ENDDO ! ig 56 do ig = 1,ngrid 57 ! Calculating the ice cover thickness 58 icedepth = icecover(ig)/rho_ice 92 59 93 !======================================================================= 94 RETURN 95 END 60 ! If the ice cover is too thick or watercaptag = true, the entire column is changed: 61 if (icedepth >= layer_PEM(nsoil)) then 62 do ik = 1,nsoil 63 newtherm_i(ig,ik) = max(inert_h2o_ice,prev_thermi(ig,ik)) 64 enddo 65 ! We neglect the effect of a very thin ice cover: 66 else if (icedepth < layer_PEM(1)) then 67 do ik = 1,nsoil 68 newtherm_i(ig,ik) = inertiedat_PEM(ig,ik) 69 enddo 70 else 71 ! Ice/regolith boundary index: 72 iref = 1 73 ! Otherwise, we find the ice/regolith boundary: 74 do ik=1,nsoil-1 75 if ((icedepth >= layer_PEM(ik)) .and. (icedepth < layer_PEM(ik + 1))) then 76 iref = ik + 1 77 exit 78 endif 79 enddo 80 ! And we change the thermal inertia: 81 do ik = 1,iref - 1 82 newtherm_i(ig,ik) = max(inert_h2o_ice,prev_thermi(ig,ik)) 83 enddo 84 ! Transition (based on the equations of thermal conduction): 85 newtherm_i(ig,iref) = sqrt((layer_PEM(iref) - layer_PEM(iref-1))/(((icedepth - layer_PEM(iref - 1))/newtherm_i(ig,iref - 1)**2) & 86 + ((layer_PEM(iref) - icedepth)/inertiedat_PEM(ig,ik)**2) ) ) 87 ! Underlying regolith: 88 do ik = iref + 1,nsoil 89 newtherm_i(ig,ik) = inertiedat_PEM(ig,ik) 90 enddo 91 endif ! icedepth 92 enddo ! ig 93 94 return 95 96 END SUBROUTINE soil_TIfeedback_PEM 97 98 END MODULE soil_TIfeedback_PEM_mod -
trunk/LMDZ.COMMON/libf/evolution/soil_pem_compute_mod.F90
r3075 r3076 1 subroutine soil_pem_routine(ngrid,nsoil,firstcall, & 2 therm_i,timestep,tsurf,tsoil) 1 MODULE soil_pem_compute_mod 3 2 3 implicit none 4 4 5 use comsoil_h_PEM, only: layer_PEM, mlayer_PEM, & 6 mthermdiff_PEM, thermdiff_PEM, coefq_PEM, & 7 coefd_PEM, mu_PEM,alph_PEM,beta_PEM,fluxgeo 8 use comsoil_h,only: volcapa 9 implicit none 5 !======================================================================= 6 contains 7 !======================================================================= 8 9 SUBROUTINE soil_pem_compute(ngrid,nsoil,firstcall,therm_i,timestep,tsurf,tsoil) 10 11 use comsoil_h_PEM, only: layer_PEM, mlayer_PEM, mthermdiff_PEM, thermdiff_PEM, coefq_PEM, coefd_PEM, mu_PEM, alph_PEM, beta_PEM, fluxgeo 12 use comsoil_h, only: volcapa 13 14 implicit none 10 15 11 16 !----------------------------------------------------------------------- … … 23 28 ! --------- 24 29 ! inputs: 25 integer,intent(in) :: ngrid! number of (horizontal) grid-points26 integer,intent(in) :: nsoil! number of soil layers27 logical,intent(in) :: firstcall! identifier for initialization call28 real,intent(in) :: therm_i(ngrid,nsoil)! thermal inertia [SI]29 real,intent(in) :: timestep! time step [s]30 real,intent(in) :: tsurf(ngrid)! surface temperature [K]30 integer, intent(in) :: ngrid ! number of (horizontal) grid-points 31 integer, intent(in) :: nsoil ! number of soil layers 32 logical, intent(in) :: firstcall ! identifier for initialization call 33 real, dimension(ngrid,nsoil), intent(in) :: therm_i ! thermal inertia [SI] 34 real, intent(in) :: timestep ! time step [s] 35 real, dimension(ngrid), intent(in) :: tsurf ! surface temperature [K] 31 36 32 37 ! outputs: 33 real,intent(inout) :: tsoil(ngrid,nsoil)! soil (mid-layer) temperature [K]38 real, dimension(ngrid,nsoil), intent(inout) :: tsoil ! soil (mid-layer) temperature [K] 34 39 ! local variables: 35 integer ig,ik40 integer :: ig, ik 36 41 37 42 ! 0. Initialisations and preprocessing step 38 43 if (firstcall) then 39 40 44 ! 0.1 Build mthermdiff_PEM(:), the mid-layer thermal diffusivities 41 do ig=1,ngrid42 do ik =0,nsoil-143 mthermdiff_PEM(ig,ik)=therm_i(ig,ik+1)*therm_i(ig,ik+1)/volcapa44 45 45 do ig = 1,ngrid 46 do ik = 0,nsoil - 1 47 mthermdiff_PEM(ig,ik) = therm_i(ig,ik + 1)*therm_i(ig,ik + 1)/volcapa 48 enddo 49 enddo 46 50 47 51 ! 0.2 Build thermdiff(:), the "interlayer" thermal diffusivities 48 do ig=1,ngrid 49 do ik=1,nsoil-1 50 thermdiff_PEM(ig,ik)=((layer_PEM(ik)-mlayer_PEM(ik-1))*mthermdiff_PEM(ig,ik) & 51 +(mlayer_PEM(ik)-layer_PEM(ik))*mthermdiff_PEM(ig,ik-1)) & 52 /(mlayer_PEM(ik)-mlayer_PEM(ik-1)) 53 enddo 54 enddo 52 do ig = 1,ngrid 53 do ik = 1,nsoil - 1 54 thermdiff_PEM(ig,ik) = ((layer_PEM(ik) - mlayer_PEM(ik - 1))*mthermdiff_PEM(ig,ik) & 55 + (mlayer_PEM(ik) - layer_PEM(ik))*mthermdiff_PEM(ig,ik - 1))/(mlayer_PEM(ik) - mlayer_PEM(ik - 1)) 56 enddo 57 enddo 55 58 56 59 ! 0.3 Build coefficients mu_PEM, q_{k+1/2}, d_k, alph_PEMa_k and capcal 57 58 mu_PEM=mlayer_PEM(0)/(mlayer_PEM(1)-mlayer_PEM(0))60 ! mu_PEM 61 mu_PEM = mlayer_PEM(0)/(mlayer_PEM(1) - mlayer_PEM(0)) 59 62 60 ! q_{1/2} 61 coefq_PEM(0)=volcapa*layer_PEM(1)/timestep 62 ! q_{k+1/2} 63 do ik=1,nsoil-1 64 coefq_PEM(ik)=volcapa*(layer_PEM(ik+1)-layer_PEM(ik)) & 65 /timestep 66 enddo 63 ! q_{1/2} 64 coefq_PEM(0) = volcapa*layer_PEM(1)/timestep 65 ! q_{k+1/2} 66 do ik = 1,nsoil - 1 67 coefq_PEM(ik) = volcapa*(layer_PEM(ik + 1) - layer_PEM(ik))/timestep 68 enddo 67 69 68 do ig=1,ngrid 69 ! d_k 70 do ik=1,nsoil-1 71 coefd_PEM(ig,ik)=thermdiff_PEM(ig,ik)/(mlayer_PEM(ik)-mlayer_PEM(ik-1)) 72 enddo 73 74 ! alph_PEM_{N-1} 75 alph_PEM(ig,nsoil-1)=coefd_PEM(ig,nsoil-1)/ & 76 (coefq_PEM(nsoil-1)+coefd_PEM(ig,nsoil-1)) 70 do ig = 1,ngrid 71 ! d_k 72 do ik = 1,nsoil - 1 73 coefd_PEM(ig,ik) = thermdiff_PEM(ig,ik)/(mlayer_PEM(ik)-mlayer_PEM(ik - 1)) 74 enddo 75 76 ! alph_PEM_{N-1} 77 alph_PEM(ig,nsoil - 1) = coefd_PEM(ig,nsoil-1)/(coefq_PEM(nsoil - 1) + coefd_PEM(ig,nsoil - 1)) 77 78 ! alph_PEM_k 78 do ik=nsoil-2,1,-1 79 alph_PEM(ig,ik)=coefd_PEM(ig,ik)/(coefq_PEM(ik)+coefd_PEM(ig,ik+1)* & 80 (1.-alph_PEM(ig,ik+1))+coefd_PEM(ig,ik)) 81 enddo 82 79 do ik = nsoil - 2,1,-1 80 alph_PEM(ig,ik) = coefd_PEM(ig,ik)/(coefq_PEM(ik) + coefd_PEM(ig,ik + 1)*(1. - alph_PEM(ig,ik + 1)) + coefd_PEM(ig,ik)) 81 enddo 83 82 enddo ! of do ig=1,ngrid 84 85 83 endif ! of if (firstcall) 86 84 87 IF (.not.firstcall) THEN88 ! 85 IF (.not. firstcall) THEN 86 ! 2. Compute soil temperatures 89 87 ! First layer: 90 do ig=1,ngrid 91 tsoil(ig,1)=(tsurf(ig)+mu_PEM*beta_PEM(ig,1)* & 92 thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0))/ & 93 (1.+mu_PEM*(1.0-alph_PEM(ig,1))*& 94 thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0)) 88 do ig = 1,ngrid 89 tsoil(ig,1) = (tsurf(ig) + mu_PEM*beta_PEM(ig,1)*thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0))/ & 90 (1. + mu_PEM*(1. - alph_PEM(ig,1))*thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0)) 95 91 96 92 ! Other layers: 97 do ik=1,nsoil-1 98 tsoil(ig,ik+1)=alph_PEM(ig,ik)*tsoil(ig,ik)+beta_PEM(ig,ik) 99 enddo 93 do ik = 1,nsoil - 1 94 tsoil(ig,ik + 1) = alph_PEM(ig,ik)*tsoil(ig,ik) + beta_PEM(ig,ik) 100 95 enddo 101 ENDIF 96 enddo 97 endif 102 98 103 99 ! 2. Compute beta_PEM coefficients (preprocessing for next time step) 104 100 ! Bottom layer, beta_PEM_{N-1} 105 do ig=1,ngrid 106 beta_PEM(ig,nsoil-1)=coefq_PEM(nsoil-1)*tsoil(ig,nsoil) & 107 /(coefq_PEM(nsoil-1)+coefd_PEM(ig,nsoil-1)) & 108 + fluxgeo/(coefq_PEM(nsoil-1)+coefd_PEM(ig,nsoil-1)) 109 enddo 101 do ig = 1,ngrid 102 beta_PEM(ig,nsoil - 1) = coefq_PEM(nsoil - 1)*tsoil(ig,nsoil)/(coefq_PEM(nsoil - 1) + coefd_PEM(ig,nsoil - 1)) & 103 + fluxgeo/(coefq_PEM(nsoil - 1) + coefd_PEM(ig,nsoil - 1)) 104 enddo 110 105 ! Other layers 111 do ik=nsoil-2,1,-1 112 do ig=1,ngrid 113 beta_PEM(ig,ik)=(coefq_PEM(ik)*tsoil(ig,ik+1)+ & 114 coefd_PEM(ig,ik+1)*beta_PEM(ig,ik+1))/ & 115 (coefq_PEM(ik)+coefd_PEM(ig,ik+1)*(1.0-alph_PEM(ig,ik+1)) & 116 +coefd_PEM(ig,ik)) 117 enddo 118 enddo 106 do ik = nsoil-2,1,-1 107 do ig = 1,ngrid 108 beta_PEM(ig,ik) = (coefq_PEM(ik)*tsoil(ig,ik + 1) + coefd_PEM(ig,ik + 1)*beta_PEM(ig,ik + 1))/ & 109 (coefq_PEM(ik) + coefd_PEM(ig,ik + 1)*(1. - alph_PEM(ig,ik + 1)) + coefd_PEM(ig,ik)) 110 enddo 111 enddo 119 112 120 end 113 END SUBROUTINE soil_pem_compute 121 114 115 END MODULE soil_pem_compute_mod -
trunk/LMDZ.COMMON/libf/evolution/soil_pem_ini_mod.F90
r3075 r3076 1 subroutine soil_pem_ini(ngrid,nsoil,therm_i,tsurf,tsoil) 1 MODULE soil_pem_ini_mod 2 2 3 implicit none 3 4 4 use comsoil_h_PEM, only: layer_PEM, mlayer_PEM, & 5 mthermdiff_PEM, thermdiff_PEM, coefq_PEM, & 6 coefd_PEM, mu_PEM,alph_PEM,beta_PEM,fluxgeo 7 use comsoil_h,only: volcapa 8 implicit none 5 !======================================================================= 6 contains 7 !======================================================================= 8 9 SUBROUTINE soil_pem_ini(ngrid,nsoil,therm_i,tsurf,tsoil) 10 11 use comsoil_h_PEM, only: layer_PEM, mlayer_PEM, mthermdiff_PEM, thermdiff_PEM, coefq_PEM, coefd_PEM, mu_PEM, alph_PEM, beta_PEM, fluxgeo 12 use comsoil_h, only: volcapa 13 14 implicit none 9 15 10 16 !----------------------------------------------------------------------- 11 17 ! Author: LL 12 18 ! Purpose: Compute soil temperature using an implict 1st order scheme, stationnary solution 13 ! 14 ! Note: depths of layers and mid-layers, soil thermal inertia and 19 ! 20 ! Note: depths of layers and mid-layers, soil thermal inertia and 15 21 ! heat capacity are commons in comsoil_PEM.h 16 22 !----------------------------------------------------------------------- … … 22 28 ! --------- 23 29 ! inputs: 24 integer,intent(in) :: ngrid ! number of (horizontal) grid-points 25 integer,intent(in) :: nsoil ! number of soil layers 26 real,intent(in) :: therm_i(ngrid,nsoil)! thermal inertia [SI]27 real,intent(in) :: tsurf(ngrid)! surface temperature [K]30 integer, intent(in) :: ngrid ! number of (horizontal) grid-points 31 integer, intent(in) :: nsoil ! number of soil layers 32 real, dimension(ngrid,nsoil), intent(in) :: therm_i ! thermal inertia [SI] 33 real, dimension(ngrid), intent(in) :: tsurf ! surface temperature [K] 28 34 29 35 ! outputs: 30 real,intent(inout) :: tsoil(ngrid,nsoil)! soil (mid-layer) temperature [K]36 real, dimension(ngrid,nsoil), intent(inout) :: tsoil ! soil (mid-layer) temperature [K] 31 37 ! local variables: 32 integer ig,ik,iloop 38 integer :: ig, ik, iloop 33 39 34 40 ! 0. Initialisations and preprocessing step 35 36 41 ! 0.1 Build mthermdiff_PEM(:), the mid-layer thermal diffusivities 37 do ig=1,ngrid38 do ik=0,nsoil-139 mthermdiff_PEM(ig,ik)=therm_i(ig,ik+1)*therm_i(ig,ik+1)/volcapa 40 41 42 do ig = 1,ngrid 43 do ik = 0,nsoil - 1 44 mthermdiff_PEM(ig,ik) = therm_i(ig,ik + 1)*therm_i(ig,ik + 1)/volcapa 45 enddo 46 enddo 42 47 43 48 ! 0.2 Build thermdiff(:), the "interlayer" thermal diffusivities 44 do ig=1,ngrid 45 do ik=1,nsoil-1 46 thermdiff_PEM(ig,ik)=((layer_PEM(ik)-mlayer_PEM(ik-1))*mthermdiff_PEM(ig,ik) & 47 +(mlayer_PEM(ik)-layer_PEM(ik))*mthermdiff_PEM(ig,ik-1)) & 48 /(mlayer_PEM(ik)-mlayer_PEM(ik-1)) 49 enddo 50 enddo 49 do ig = 1,ngrid 50 do ik = 1,nsoil - 1 51 thermdiff_PEM(ig,ik) = ((layer_PEM(ik) - mlayer_PEM(ik - 1))*mthermdiff_PEM(ig,ik) & 52 + (mlayer_PEM(ik) - layer_PEM(ik))*mthermdiff_PEM(ig,ik - 1))/(mlayer_PEM(ik) - mlayer_PEM(ik - 1)) 53 enddo 54 enddo 51 55 52 56 ! 0.3 Build coefficients mu_PEM, q_{k+1/2}, d_k, alph_PEMa_k and capcal 53 54 mu_PEM=mlayer_PEM(0)/(mlayer_PEM(1)-mlayer_PEM(0))57 ! mu_PEM 58 mu_PEM = mlayer_PEM(0)/(mlayer_PEM(1) - mlayer_PEM(0)) 55 59 56 57 58 60 ! q_{1/2} 61 coefq_PEM(:) = 0. 62 ! q_{k+1/2} 59 63 60 do ig=1,ngrid 61 ! d_k 62 do ik=1,nsoil-1 63 coefd_PEM(ig,ik)=thermdiff_PEM(ig,ik)/(mlayer_PEM(ik)-mlayer_PEM(ik-1)) 64 enddo 65 66 ! alph_PEM_{N-1} 67 alph_PEM(ig,nsoil-1)=coefd_PEM(ig,nsoil-1)/ & 68 (coefq_PEM(nsoil-1)+coefd_PEM(ig,nsoil-1)) 69 ! alph_PEM_k 70 do ik=nsoil-2,1,-1 71 alph_PEM(ig,ik)=coefd_PEM(ig,ik)/(coefq_PEM(ik)+coefd_PEM(ig,ik+1)* & 72 (1.-alph_PEM(ig,ik+1))+coefd_PEM(ig,ik)) 73 enddo 64 do ig = 1,ngrid 65 ! d_k 66 do ik = 1,nsoil-1 67 coefd_PEM(ig,ik) = thermdiff_PEM(ig,ik)/(mlayer_PEM(ik) - mlayer_PEM(ik - 1)) 68 enddo 74 69 75 enddo ! of do ig=1,ngrid 70 ! alph_PEM_{N-1} 71 alph_PEM(ig,nsoil - 1) = coefd_PEM(ig,nsoil - 1)/(coefq_PEM(nsoil - 1) + coefd_PEM(ig,nsoil - 1)) 72 ! alph_PEM_k 73 do ik = nsoil - 2,1,-1 74 alph_PEM(ig,ik) = coefd_PEM(ig,ik)/(coefq_PEM(ik) + coefd_PEM(ig,ik + 1)*(1. - alph_PEM(ig,ik + 1)) + coefd_PEM(ig,ik)) 75 enddo 76 enddo ! of do ig=1,ngrid 76 77 77 78 79 ! 1. Compute beta_PEM coefficients 78 ! 1. Compute beta_PEM coefficients 80 79 ! Bottom layer, beta_PEM_{N-1} 81 do ig=1,ngrid 82 beta_PEM(ig,nsoil-1)=coefq_PEM(nsoil-1)*tsoil(ig,nsoil) & 83 /(coefq_PEM(nsoil-1)+coefd_PEM(ig,nsoil-1)) & 84 + fluxgeo/(coefq_PEM(nsoil-1)+coefd_PEM(ig,nsoil-1)) 85 enddo 80 do ig = 1,ngrid 81 beta_PEM(ig,nsoil - 1) = coefq_PEM(nsoil - 1)*tsoil(ig,nsoil)/(coefq_PEM(nsoil - 1) + coefd_PEM(ig,nsoil - 1)) & 82 + fluxgeo/(coefq_PEM(nsoil - 1) + coefd_PEM(ig,nsoil - 1)) 83 enddo 86 84 ! Other layers 87 do ik=nsoil-2,1,-1 88 do ig=1,ngrid 89 beta_PEM(ig,ik)=(coefq_PEM(ik)*tsoil(ig,ik+1)+ & 90 coefd_PEM(ig,ik+1)*beta_PEM(ig,ik+1))/ & 91 (coefq_PEM(ik)+coefd_PEM(ig,ik+1)*(1.0-alph_PEM(ig,ik+1)) & 92 +coefd_PEM(ig,ik)) 93 enddo 94 enddo 85 do ik = nsoil - 2,1,-1 86 do ig = 1,ngrid 87 beta_PEM(ig,ik) = (coefq_PEM(ik)*tsoil(ig,ik + 1) + coefd_PEM(ig,ik+1)*beta_PEM(ig,ik + 1))/ & 88 (coefq_PEM(ik) + coefd_PEM(ig,ik + 1)*(1. - alph_PEM(ig,ik + 1)) + coefd_PEM(ig,ik)) 89 enddo 90 enddo 95 91 96 92 ! 2. Compute soil temperatures 97 93 do iloop = 1,10 !just convergence 98 ! First layer: 99 do ig=1,ngrid 100 tsoil(ig,1)=(tsurf(ig)+mu_PEM*beta_PEM(ig,1)* & 101 thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0))/ & 102 (1.+mu_PEM*(1.0-alph_PEM(ig,1))*& 103 thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0)) 104 ! Other layers: 105 do ik=1,nsoil-1 106 tsoil(ig,ik+1)=alph_PEM(ig,ik)*tsoil(ig,ik)+beta_PEM(ig,ik) 107 enddo 108 enddo 109 110 enddo ! iloop 111 end 94 ! First layer: 95 do ig = 1,ngrid 96 tsoil(ig,1)=(tsurf(ig) + mu_PEM*beta_PEM(ig,1)*thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0))/ & 97 (1. + mu_PEM*(1. - alph_PEM(ig,1))*thermdiff_PEM(ig,1)/mthermdiff_PEM(ig,0)) 98 ! Other layers: 99 do ik = 1,nsoil - 1 100 tsoil(ig,ik + 1) = alph_PEM(ig,ik)*tsoil(ig,ik) + beta_PEM(ig,ik) 101 enddo 102 enddo 112 103 104 enddo ! iloop 105 106 END SUBROUTINE soil_pem_ini 107 108 END MODULE soil_pem_ini_mod -
trunk/LMDZ.COMMON/libf/evolution/soil_settings_PEM_mod.F90
r3075 r3076 1 subroutine soil_settings_PEM(ngrid,nslope,nsoil_PEM,nsoil_GCM, 2 & TI_GCM,TI_PEM) 1 MODULE soil_settings_PEM_mod 3 2 3 implicit none 4 5 !======================================================================= 6 contains 7 !======================================================================= 8 9 SUBROUTINE soil_settings_PEM(ngrid,nslope,nsoil_PEM,nsoil_GCM,TI_GCM,TI_PEM) 4 10 5 11 ! use netcdf 6 use comsoil_h_PEM, only: layer_PEM, mlayer_PEM, 7 & depth_breccia,depth_bedrock,index_breccia,index_bedrock 8 use comsoil_h, only: inertiedat,layer,mlayer, volcapa 12 use comsoil_h_PEM, only: layer_PEM, mlayer_PEM, depth_breccia, depth_bedrock, index_breccia, index_bedrock 13 use comsoil_h, only: inertiedat, layer, mlayer, volcapa 9 14 15 use iostart, only: inquire_field_ndims, get_var, get_field, inquire_field, inquire_dimension_length 10 16 11 use iostart, only: inquire_field_ndims, get_var, get_field, 12 & inquire_field, inquire_dimension_length 17 implicit none 13 18 14 implicit none 15 16 !====================================================================== 19 !======================================================================= 17 20 ! Author: LL, based on work by Ehouarn Millour (07/2006) 18 21 ! 19 22 ! Purpose: Read and/or initialise soil depths and properties 20 23 ! 21 ! Modifications: Aug.2010 EM : use NetCDF90 to load variables (enables using 22 ! r4 or r8 restarts independently of having compiled 23 ! the GCM in r4 or r8) 24 ! June 2013 TN : Possibility to read files with a time axis 25 ! 24 ! Modifications: Aug.2010 EM: use NetCDF90 to load variables (enables using 25 ! r4 or r8 restarts independently of having compiled 26 ! the GCM in r4 or r8) 27 ! June 2013 TN: Possibility to read files with a time axis 26 28 ! 27 29 ! The various actions and variable read/initialized are: 28 30 ! 1. Read/build layer (and midlayer) depth 29 ! 2. Interpolate thermal inertia and temperature on the new grid, if 30 ! necessary 31 !====================================================================== 31 ! 2. Interpolate thermal inertia and temperature on the new grid, if necessary 32 !======================================================================= 32 33 33 !====================================================================== 34 !======================================================================= 34 35 ! arguments 35 36 ! --------- 36 37 ! inputs: 37 integer,intent(in) :: ngrid ! # of horizontal grid points 38 integer,intent(in) :: nslope ! # of subslope wihtin the mesh 39 integer,intent(in) :: nsoil_PEM ! # of soil layers in the PEM 40 integer,intent(in) :: nsoil_GCM ! # of soil layers in the GCM 41 real,intent(in) :: TI_GCM(ngrid,nsoil_GCM,nslope) ! Thermal inertia in the GCM [SI] 42 real,intent(inout) :: TI_PEM(ngrid,nsoil_PEM,nslope) ! Thermal inertia in the PEM [SI] 38 integer, intent(in) :: ngrid ! # of horizontal grid points 39 integer, intent(in) :: nslope ! # of subslope wihtin the mesh 40 integer, intent(in) :: nsoil_PEM ! # of soil layers in the PEM 41 integer, intent(in) :: nsoil_GCM ! # of soil layers in the GCM 42 real, dimension(ngrid,nsoil_GCM,nslope), intent(in) :: TI_GCM ! Thermal inertia in the GCM [SI] 43 43 44 !====================================================================== 44 real, dimension(ngrid,nsoil_PEM,nslope), intent(inout) :: TI_PEM ! Thermal inertia in the PEM [SI] 45 !======================================================================= 45 46 ! local variables: 46 integer ig,iloop,islope ! loop counters 47 logical found 48 49 real alpha,lay1 ! coefficients for building layers 50 real xmin,xmax ! to display min and max of a field 51 52 !====================================================================== 53 47 integer :: ig, iloop, islope ! loop counters 48 logical :: found 49 real :: alpha,lay1 ! coefficients for building layers 50 real :: xmin, xmax ! to display min and max of a field 51 !======================================================================= 54 52 ! 1. Depth coordinate 55 53 ! ------------------- 56 57 54 ! 1.4 Build mlayer(), if necessary 58 59 60 lay1=2.e-461 alpha=262 do iloop=0,nsoil_PEM-163 mlayer_PEM(iloop)=lay1*(alpha**(iloop-0.5))64 55 ! default mlayer distribution, following a power law: 56 ! mlayer(k)=lay1*alpha**(k-1/2) 57 lay1 = 2.e-4 58 alpha = 2 59 do iloop = 0,nsoil_PEM - 1 60 mlayer_PEM(iloop) = lay1*(alpha**(iloop - 0.5)) 61 enddo 65 62 66 63 ! 1.5 Build layer(); following the same law as mlayer() 67 68 69 lay1=sqrt(mlayer_PEM(0)*mlayer_PEM(1))70 alpha=mlayer_PEM(1)/mlayer_PEM(0)71 do iloop=1,nsoil_PEM72 layer_PEM(iloop)=lay1*(alpha**(iloop-1))73 64 ! Assuming layer distribution follows mid-layer law: 65 ! layer(k)=lay1*alpha**(k-1) 66 lay1 = sqrt(mlayer_PEM(0)*mlayer_PEM(1)) 67 alpha = mlayer_PEM(1)/mlayer_PEM(0) 68 do iloop = 1,nsoil_PEM 69 layer_PEM(iloop) = lay1*(alpha**(iloop - 1)) 70 enddo 74 71 75 72 ! 2. Thermal inertia (note: it is declared in comsoil_h) 76 73 ! ------------------ 77 78 do ig = 1,ngrid 79 do islope = 1,nslope 80 do iloop = 1,nsoil_GCM 74 do ig = 1,ngrid 75 do islope = 1,nslope 76 do iloop = 1,nsoil_GCM 81 77 TI_PEM(ig,iloop,islope) = TI_GCM(ig,iloop,islope) 82 enddo83 if(nsoil_PEM.gt.nsoil_GCM) then84 do iloop = nsoil_GCM+1,nsoil_PEM85 TI_PEM(ig,iloop,islope) = TI_GCM(ig,nsoil_GCM,islope)86 enddo87 endif88 78 enddo 89 enddo 90 79 if (nsoil_PEM > nsoil_GCM) then 80 do iloop = nsoil_GCM + 1,nsoil_PEM 81 TI_PEM(ig,iloop,islope) = TI_GCM(ig,nsoil_GCM,islope) 82 enddo 83 endif 84 enddo 85 enddo 91 86 92 87 ! 3. Index for subsurface layering 93 88 ! ------------------ 94 index_breccia= 195 do iloop = 1,nsoil_PEM-196 if (depth_breccia.ge.layer_PEM(iloop)) then97 index_breccia=iloop98 99 100 101 89 index_breccia = 1 90 do iloop = 1,nsoil_PEM - 1 91 if (depth_breccia >= layer_PEM(iloop)) then 92 index_breccia = iloop 93 else 94 exit 95 endif 96 enddo 102 97 103 index_bedrock= 1104 do iloop = 1,nsoil_PEM-1105 if (depth_bedrock.ge.layer_PEM(iloop)) then106 index_bedrock=iloop107 108 109 110 98 index_bedrock = 1 99 do iloop = 1,nsoil_PEM - 1 100 if (depth_bedrock >= layer_PEM(iloop)) then 101 index_bedrock = iloop 102 else 103 exit 104 endif 105 enddo 111 106 107 END SUBROUTINE soil_settings_PEM 112 108 113 end subroutine soil_settings_PEM 109 END MODULE soil_settings_PEM_mod -
trunk/LMDZ.COMMON/libf/evolution/time_evol_mod.F90
r3039 r3076 1 1 MODULE time_evol_mod 2 2 3 IMPLICIT NONE 3 implicit none 4 4 5 integer :: year_bp_ini !Initial year (in Planetary years) of the simulation of the PEM defined in run.def (in Earth years)6 integer :: dt_pem !Time step used by the PEM in Planetary years7 real :: convert_years !Conversion ratio from Planetary years to Earth years8 real :: water_ice_criterion ! Percentage of change of the surface of water ice sublimating before stopping the PEM 9 real :: co2_ice_criterion ! Percentage of change of the surface of co2 ice sublimating before stopping the PEM 10 real :: ps_criterion !Percentage of change of averaged surface pressure before stopping the PEM11 integer :: Max_iter_pem !Maximal number of iteration when converging to a steady state, read in evol.def12 logical :: evol_orbit_pem !True if we want to follow the orbital parameters of obl_ecc_lsp.asc, read in evol.def13 logical :: var_obl ! True if we want the PEM to follow obl_ecc_lsp.asc parameters for obliquity 14 logical :: var_ecc !True if we want the PEM to follow obl_ecc_lsp.asc parameters for excenticity15 logical :: var_lsp !True if we want the PEM to follow obl_ecc_lsp.asc parameters for ls perihelie5 integer :: year_bp_ini ! Initial year (in Planetary years) of the simulation of the PEM defined in run.def (in Earth years) 6 integer :: dt_pem ! Time step used by the PEM in Planetary years 7 real :: convert_years ! Conversion ratio from Planetary years to Earth years 8 real :: water_ice_criterion ! Percentage of change of the surface of water ice sublimating before stopping the PEM 9 real :: co2_ice_criterion ! Percentage of change of the surface of co2 ice sublimating before stopping the PEM 10 real :: ps_criterion ! Percentage of change of averaged surface pressure before stopping the PEM 11 integer :: Max_iter_pem ! Maximal number of iteration when converging to a steady state, read in evol.def 12 logical :: evol_orbit_pem ! True if we want to follow the orbital parameters of obl_ecc_lsp.asc, read in evol.def 13 logical :: var_obl ! True if we want the PEM to follow obl_ecc_lsp.asc parameters for obliquity 14 logical :: var_ecc ! True if we want the PEM to follow obl_ecc_lsp.asc parameters for excenticity 15 logical :: var_lsp ! True if we want the PEM to follow obl_ecc_lsp.asc parameters for ls perihelie 16 16 17 17 END MODULE time_evol_mod -
trunk/LMDZ.MARS/deftank/pem/launch_pem.sh
r3068 r3076 168 168 mv startfi.nc startfi_evol.nc 169 169 if [ -f "start.nc" ]; then 170 cpstart.nc start_evol.nc170 mv start.nc start_evol.nc 171 171 elif [ -f "start1D.txt" ]; then 172 cpstart1D.txt start1D_evol.txt172 mv start1D.txt start1D_evol.txt 173 173 fi 174 174 ./$exePEM > out_runPEM${iPEM} 2>&1
Note: See TracChangeset
for help on using the changeset viewer.