- Timestamp:
- Jul 22, 2023, 12:54:11 PM (16 months ago)
- Location:
- trunk/LMDZ.MARS
- Files:
-
- 11 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/changelog.txt
r3007 r3008 4120 4120 Fix OpenMP bug in paleoclimate_mod; saved variables should be threadprivate. 4121 4121 4122 == 22/07/2023 == EM 4123 Some code cleanup around microphysics. Turn microphys.h into module 4124 microphys_h.F90, and while at it also turn nuclea.F, growthrate.F90 and 4125 massflowrateco2.F90 into modules. -
trunk/LMDZ.MARS/libf/phymars/co2cloud.F90
r2932 r3008 108 108 109 109 use improvedCO2clouds_mod, only: improvedCO2clouds 110 use microphys_h, only: nbinco2_cld, rad_cldco2, mco2 110 111 use write_output_mod, only: write_output 111 112 #ifndef MESOSCALE … … 116 117 117 118 include "callkeys.h" 118 include "microphys.h"119 119 !----------------------------------------------------------------------------------------------------------------------! 120 120 ! VARIABLES DECLARATION -
trunk/LMDZ.MARS/libf/phymars/conf_phys.F
r2999 r3008 55 55 USE mod_phys_lmdz_transfert_para, ONLY: bcast 56 56 USE paleoclimate_mod,ONLY: paleoclimate,albedo_perenialco2 57 use microphys_h, only: mteta 58 57 59 IMPLICIT NONE 60 58 61 include "callkeys.h" 59 include "microphys.h"60 62 61 63 INTEGER,INTENT(IN) :: ngrid,nlayer,nq 64 62 65 INTEGER ierr,j 63 66 character(len=20),parameter :: modname="conf_phys" -
trunk/LMDZ.MARS/libf/phymars/growthrate.F
r2407 r3008 1 MODULE growthrate_mod 2 3 IMPLICIT NONE 4 5 CONTAINS 6 1 7 subroutine growthrate(temp,pmid,psat,rcrystal,res,Dv) 2 8 3 9 use tracer_mod, only: rho_ice 4 USE comcstfi_h 10 use comcstfi_h, only: pi 11 use microphys_h, only: kbz, mh2o, mco2, molco2, molh2o 12 use microphys_h, only: nav, rgp, To 13 5 14 IMPLICIT NONE 6 15 … … 20 29 c ------------- 21 30 22 #include "microphys.h"23 24 31 c 25 32 c arguments: … … 27 34 28 35 c Input 29 REAL temp ! temperature in the middle of the layer (K)30 REAL pmid ! pressure in the middle of the layer (K)31 REAL psat ! water vapor saturation pressure (Pa)32 REAL rcrystal ! crystal radius before condensation (m)36 REAL, INTENT(IN) :: temp ! temperature in the middle of the layer (K) 37 REAL, INTENT(IN) :: pmid ! pressure in the middle of the layer (K) 38 REAL, INTENT(IN) :: psat ! water vapor saturation pressure (Pa) 39 REAL, INTENT(IN) :: rcrystal ! crystal radius before condensation (m) 33 40 34 41 c Output 35 REAL res ! growth resistance (res=Rk+Rd)36 REAL Dv ! water vapor diffusion coefficient42 REAL, INTENT(OUT) :: res ! growth resistance (res=Rk+Rd) 43 REAL, INTENT(OUT) :: Dv ! water vapor diffusion coefficient 37 44 38 45 c local: … … 100 107 c dr = rf-r 101 108 102 RETURN 103 END 109 end subroutine growthrate 110 111 END MODULE growthrate_mod 104 112 -
trunk/LMDZ.MARS/libf/phymars/hdo_surfex_mod.F
r2932 r3008 16 16 use geometry_mod, only: longitude_deg,latitude_deg 17 17 use comcstfi_h, only: pi 18 use microphys_h, only: nav, kbz, mh2o, mco2, mhdo 19 use microphys_h, only: molco2, molh2o, molhdo 18 20 use write_output_mod, only: write_output 19 21 … … 25 27 c------------------------------------------------------------------ 26 28 include "callkeys.h" 27 include "microphys.h"28 29 c------------------------------------------------------------------ 29 30 c Arguments: -
trunk/LMDZ.MARS/libf/phymars/improvedclouds_mod.F
r2988 r3008 18 18 use conc_mod, only: mmean 19 19 use comcstfi_h, only: pi, cpp 20 use microphys_h, only: nbin_cld, rad_cld, mteta, kbz, nav, rgp 21 use microphys_h, only: mco2, vo1, mh2o, mhdo, molco2, molhdo, To 22 use nuclea_mod, only: nuclea 23 use growthrate_mod, only: growthrate 20 24 use write_output_mod, only: write_output 21 25 implicit none … … 43 47 c J. Naar, adaptative subtimestep now done here (June 2023) 44 48 c------------------------------------------------------------------ 45 #include "callkeys.h" 46 #include "microphys.h" 49 include "callkeys.h" 47 50 c------------------------------------------------------------------ 48 51 c Inputs/outputs: … … 66 69 c Local variables: 67 70 68 LOGICAL firstcall 69 DATA firstcall/.true./ 70 SAVE firstcall 71 71 LOGICAL, SAVE :: firstcall = .true. 72 72 !$OMP THREADPRIVATE(firstcall) 73 73 … … 116 116 DOUBLE PRECISION, PARAMETER :: rbmax_cld = 1.e-2 ! Maximum boundary radius (m) 117 117 DOUBLE PRECISION vrat_cld ! Volume ratio 118 DOUBLE PRECISION rb_cld(nbin_cld+1)! boundary values of each rad_cld bin (m) 119 SAVE rb_cld 118 DOUBLE PRECISION, SAVE :: rb_cld(nbin_cld+1)! boundary values of each rad_cld bin (m) 119 !$OMP THREADPRIVATE(rb_cld) 120 120 121 DOUBLE PRECISION dr_cld(nbin_cld) ! width of each rad_cld bin (m) 121 122 DOUBLE PRECISION vol_cld(nbin_cld) ! particle volume for each bin (m3) 122 123 !$OMP THREADPRIVATE(rb_cld) 124 125 126 REAL sigma_ice ! Variance of the ice and CCN distributions 127 SAVE sigma_ice 128 123 124 REAL, SAVE :: sigma_ice ! Variance of the ice and CCN distributions 129 125 !$OMP THREADPRIVATE(sigma_ice) 130 126 … … 152 148 INTEGER countcells 153 149 154 LOGICAL test_flag ! flag for test/debuging outputs 155 SAVE test_flag 156 150 LOGICAL, SAVE :: test_flag ! flag for test/debuging outputs 157 151 !$OMP THREADPRIVATE(test_flag) 158 152 … … 221 215 c Contact parameter of water ice on dust ( m=cos(theta) ) 222 216 c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 223 ! mteta = 0.95217 ! mteta is initialized in conf_phys 224 218 write(*,*) 'water_param contact parameter:', mteta 225 219 -
trunk/LMDZ.MARS/libf/phymars/improvedco2clouds_mod.F90
r2660 r3008 76 76 use nucleaco2_mod, only: nucleaco2 77 77 use datafile_mod, only: datadir 78 78 use massflowrateco2_mod, only: massflowrateco2 79 79 use density_co2_ice_mod, only: density_co2_ice 80 use microphys_h, only: nbinco2_cld, rad_cldco2, m0co2, mco2 81 use microphys_h, only: mteta, mtetaco2 80 82 81 83 implicit none 82 84 83 85 include "callkeys.h" 84 include "microphys.h" 86 85 87 !----------------------------------------------------------------------------------------------------------------------! 86 88 ! VARIABLES DECLARATION -
trunk/LMDZ.MARS/libf/phymars/massflowrateco2.F90
r2389 r3008 1 MODULE massflowrateco2_mod 2 3 IMPLICIT NONE 4 5 CONTAINS 6 1 7 subroutine massflowrateco2(P,T,Sat,Radius,Matm,Ic) 2 8 !======================================================================================================================! … … 18 24 implicit none 19 25 20 include "microphys.h"21 26 !----------------------------------------------------------------------------------------------------------------------! 22 27 ! VARIABLES DECLARATION … … 84 89 use tracer_mod, only: rho_ice_co2 85 90 use comcstfi_h, only: pi 91 use microphys_h, only: kbz, mco2, nav, rgp, sigco2 86 92 87 93 implicit none 88 include "microphys.h" 94 89 95 !----------------------------------------------------------------------------------------------------------------------! 90 96 ! VARIABLES DECLARATION … … 211 217 ! Compute diffusion coefficient CO2/N2 cited in Ilona's lecture - from Reid et al. 1987 212 218 !======================================================================================================================! 219 use microphys_h, only: mco2, mn2 220 213 221 implicit none 214 222 215 include "microphys.h"216 223 !----------------------------------------------------------------------------------------------------------------------! 217 224 ! VARIABLES DECLARATION … … 250 257 Diff = 0.00143 * dble(T)**(1.75) / (dble(Pbar) * sqrt(Mab) * (dble(dva)**(1./3.) + dble(dvb)**(1./3.))**2.) 251 258 252 return253 259 !======================================================================================================================! 254 260 ! END =================================================================================================================! … … 266 272 ! Compute thermal conductivity of CO2/N2 mixture (***WITHOUT*** USE OF VISCOSITY (Mason & Saxena 1958 - Wassiljeva 1904) 267 273 !======================================================================================================================! 274 use microphys_h, only: mco2, mn2 275 268 276 implicit none 269 277 270 include "microphys.h"271 278 !----------------------------------------------------------------------------------------------------------------------! 272 279 ! VARIABLES DECLARATION … … 360 367 ! Compute thermal cond of N2 (Lemmon and Jacobsen, 2003) WITH viscosity 361 368 !======================================================================================================================! 369 use microphys_h, only: mn2 370 362 371 implicit none 363 372 364 include "microphys.h"365 373 !----------------------------------------------------------------------------------------------------------------------! 366 374 ! VARIABLES DECLARATION … … 475 483 ! Compute viscosity of N2 (Lemmon and Jacobsen, 2003) 476 484 !======================================================================================================================! 485 use microphys_h, only: mn2 486 477 487 implicit none 478 488 479 include "microphys.h"480 489 !----------------------------------------------------------------------------------------------------------------------! 481 490 ! VARIABLES DECLARATION … … 617 626 !======================================================================================================================! 618 627 end subroutine KthCO2Scalab 628 629 END MODULE massflowrateco2_mod -
trunk/LMDZ.MARS/libf/phymars/microphys_h.F90
r3007 r3008 1 MODULE microphys_h 2 3 IMPLICIT NONE 1 4 !----------------------------------------------------------------------- 2 ! INCLUDE 'microphys.h' 3 ! Parameters and physical constants used by the microphysal scheme; 5 ! Parameters and physical constants used by the microphysal schemes; 4 6 ! Parameters for CO2 microphysics are also in this file 5 7 !----------------------------------------------------------------------- … … 48 50 ! Contact parameter ( m=cos(theta) ) 49 51 ! (initialized in improvedclouds.F) 50 REAL mteta 52 REAL, SAVE :: mteta 53 !$OMP THREADPRIVATE(mteta) 51 54 52 55 ! Volume of a water molecule (m3) 53 DOUBLE PRECISION vo1 56 DOUBLE PRECISION, SAVE :: vo1 57 !$OMP THREADPRIVATE(vo1) 54 58 ! Radius used by the microphysical scheme (m) 55 DOUBLE PRECISION rad_cld(nbin_cld) 59 DOUBLE PRECISION, SAVE :: rad_cld(nbin_cld) 60 !$OMP THREADPRIVATE(rad_cld) 56 61 57 62 58 63 64 !!!!!!!!!!!!!!!! CO2 part 59 65 60 !CO2 part61 66 ! number of bins for nucleation 62 67 INTEGER, PARAMETER :: nbinco2_cld=100 … … 78 83 DOUBLE PRECISION, PARAMETER :: m0co2 = mco2 / nav 79 84 ! Contact parameter ( m=cos(theta) ) 80 ! (initialized in improvedCO2clouds.F)81 85 ! bachnar 2016 value :0.78 82 86 !old value 0.95 83 87 REAL, parameter :: mtetaco2 = 0.95 88 84 89 ! Volume of a co2 molecule (m3) 85 DOUBLE PRECISION :: vo1co2 90 DOUBLE PRECISION, SAVE :: vo1co2 91 !$OMP THREADPRIVATE(vo1co2) 92 86 93 ! Radius used by the microphysical scheme (m) 87 DOUBLE PRECISION :: rad_cldco2(nbinco2_cld) 88 REAL, parameter :: threshJA = 1 89 ! COMMON/microphys/vo1co2,rad_cldco2 94 DOUBLE PRECISION, SAVE :: rad_cldco2(nbinco2_cld) 95 !$OMP THREADPRIVATE(rad_cldco2) 90 96 91 ! NB: to keep commons aligned: 92 ! split them in groups (reals, integers and characters) 93 94 COMMON/microphys/rad_cld,vo1,rad_cldco2,vo1co2 95 COMMON/microphys_2/mteta 96 !$OMP THREADPRIVATE(/microphys/) 97 !$OMP THREADPRIVATE(/microphys_2/) 98 97 REAL, parameter :: threshJA = 1 99 98 100 ! EXAMPLE: 101 ! COMMON/tracer/radius,rho_q,alpha_lift,alpha_devil,mmol, & 102 ! & varian,r3n_q,rho_dust,rho_ice,nuice_ref,nuice_sed, & 103 ! & ref_r0,dryness 104 !----------------------------------------------------------------------- 99 END MODULE microphys_h -
trunk/LMDZ.MARS/libf/phymars/nuclea.F
r2616 r3008 1 ******************************************************* 2 * * 1 MODULE nuclea_mod 2 3 IMPLICIT NONE 4 5 CONTAINS 6 3 7 subroutine nuclea(ph2o,temp,sat,n_ccn,nucrate) 4 USE comcstfi_h 8 use comcstfi_h, only: pi 9 use microphys_h, only: nbin_cld, rad_cld, nav, mteta, m0 10 use microphys_h, only: desorp, kbz, nus, rgp, surfdif, vo1 5 11 implicit none 6 12 * * … … 15 21 ******************************************************* 16 22 17 #include "microphys.h"18 23 include "callkeys.h" 19 24 20 25 c Inputs 21 DOUBLE PRECISION ph2o,sat22 DOUBLE PRECISION n_ccn(nbin_cld)23 REAL temp26 DOUBLE PRECISION, INTENT(IN) :: ph2o,sat 27 DOUBLE PRECISION, INTENT(IN) :: n_ccn(nbin_cld) 28 REAL, INTENT(IN) :: temp 24 29 25 30 c Output 26 31 ! DOUBLE PRECISION nucrate(nbin_cld) 27 REAL nucrate(nbin_cld)32 REAL, INTENT(OUT) :: nucrate(nbin_cld) 28 33 29 34 c Local variables … … 35 40 DOUBLE PRECISION fistar ! Activation energy required to form a critical embryo (J) 36 41 ! DOUBLE PRECISION zeldov ! Zeldovitch factor (no dim) 37 DOUBLE PRECISION fshape ! function defined at the end of the file38 42 DOUBLE PRECISION deltaf 39 43 … … 48 52 integer i 49 53 50 LOGICAL firstcall 51 54 LOGICAL, SAVE :: firstcall = .true. 52 55 !$OMP THREADPRIVATE(firstcall) 53 54 DATA firstcall/.true./55 SAVE firstcall56 56 57 57 c ************************************************* … … 110 110 111 111 c Loop over size bins 112 do 200i=1,nbin_cld112 do i=1,nbin_cld 113 113 114 114 if ( n_ccn(i) .lt. 1e-10 ) then 115 115 c no dust, no need to compute nucleation! 116 116 nucrate(i)=0. 117 goto 200 117 ! move on to next bin 118 cycle 118 119 endif 119 120 … … 143 144 endif 144 145 145 200 continue 146 enddo ! of do i=1,nbin_cld 146 147 147 148 else … … 151 152 enddo 152 153 153 endif 154 endif ! of if (sat .gt. 1.) 154 155 155 return 156 end 156 end subroutine nuclea 157 157 158 158 ********************************************************* … … 163 163 ********************************************************* 164 164 165 double precision cost,rap165 double precision, intent(in) :: cost,rap 166 166 double precision yeah 167 167 … … 181 181 fshape = 0.5*fshape 182 182 183 return 184 end 183 end function fshape 184 185 186 END MODULE nuclea_mod -
trunk/LMDZ.MARS/libf/phymars/nucleaco2.F90
r2562 r3008 2 2 implicit none 3 3 contains 4 4 5 subroutine nucleaco2(pco2,temp,sat,n_ccn,nucrate,vo2co2, teta) 5 USE comcstfi_h 6 7 use comcstfi_h, only: pi 8 use microphys_h, only: nbinco2_cld, rad_cldco2, desorpco2, m0co2, kbz 9 use microphys_h, only: nusco2, sigco2, surfdifco2 6 10 7 11 implicit none … … 26 30 !nucleation sur dust et h2o separement ici 27 31 28 include "microphys.h"29 32 include "callkeys.h" 30 33 … … 94 97 !********************************************************* 95 98 96 double precision cost,rap99 double precision, intent(in) :: cost,rap 97 100 double precision yeah 98 101 -
trunk/LMDZ.MARS/libf/phymars/vdifc_mod.F
r2953 r3008 31 31 use comslope_mod, ONLY: nslope,def_slope,def_slope_mean, 32 32 & subslope_dist,major_slope,iflat 33 use microphys_h, only: To 33 34 34 35 IMPLICIT NONE … … 55 56 56 57 include "callkeys.h" 57 include "microphys.h"58 58 59 59 c
Note: See TracChangeset
for help on using the changeset viewer.