- Timestamp:
- Jan 21, 2020, 12:54:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dynamico_lmdz/simple_physics/phyparam/DYNAMICO/icosa_phyparam_mod.F90
r4231 r4235 1 1 MODULE icosa_phyparam_mod 2 #include "use_logging.h" 3 4 ! FCM gets confused when external modules are USEd at module level 5 ! => USE statements to DYNAMICO modules go into subroutines 6 2 7 IMPLICIT NONE 8 PRIVATE 3 9 SAVE 10 11 LOGICAL :: firstcall = .TRUE. 12 LOGICAL, PARAMETER :: lastcall = .FALSE. 13 14 REAL, PARAMETER :: oneday = 86400. ! hard-coded 15 INTEGER, PARAMETER :: log_unit = 15 16 17 PUBLIC :: init_physics, physics 4 18 5 19 CONTAINS … … 7 21 SUBROUTINE init_physics 8 22 ! DYNAMICO 9 USE mpipara, ONLY : is_mpi_master 10 USE icosa, ONLY : llm, g, radius, cpp, kappa 11 USE time_mod, ONLY : dt, itau_physics 23 USE mpipara, ONLY : is_mpi_master 24 USE icosa, ONLY : llm 25 26 USE icosa, ONLY : g, radius, cpp, kappa 12 27 USE getin_mod, ONLY : getin 13 USE physics_interface_mod 28 USE physics_interface_mod, ONLY : inout => physics_inout 14 29 ! phyparam 30 USE logging, ONLY : flush_plugin, dbtag, max_log_level 31 USE read_param_mod 15 32 USE comgeomfi 16 33 USE iniphyparam_mod 17 34 INTEGER, PARAMETER :: dayref=0 18 INTEGER :: ngrid 35 CHARACTER(10) :: physics_log_level 36 INTEGER :: ngrid, lev 37 REAL :: timestep 19 38 REAL :: unjours ! solar day in seconds 20 39 21 IF(is_mpi_master) WRITE(*,*) 'phyparam/init_physics called' 22 23 ngrid = physics_inout%ngrid 40 flush_plugin => flush_log_ 41 42 physics_log_level='INF' 43 CALL getin('physics_log_level', physics_log_level) 44 DO lev=1, SIZE(dbtag) 45 IF(dbtag(lev)==TRIM(physics_log_level)) THEN 46 max_log_level = lev 47 EXIT 48 END IF 49 END DO 50 51 read_paramr_plugin => read_paramr 52 read_parami_plugin => read_parami 53 read_paramb_plugin => read_paramb 54 55 WRITELOG(*,*) 'init_physics called' 56 WRITELOG(*,*) 'physics log level set to ', dbtag(max_log_level) 57 LOG_INFO('phyparam') 58 59 ngrid = inout%ngrid 60 timestep = inout%dt_phys 61 24 62 unjours = 86400. 25 63 CALL getin('unjours', unjours) 26 64 27 CALL init_comgeomfi(ngrid, llm, & 28 & physics_inout%lon, physics_inout%lat) 65 CALL init_comgeomfi(ngrid, llm, inout%lon, inout%lat) 29 66 CALL iniphyparam(ngrid, llm, & 30 & unjours, dayref, dt*itau_physics, &67 & unjours, dayref, timestep, & 31 68 & radius, g, cpp*kappa, cpp) 32 69 … … 34 71 35 72 SUBROUTINE physics 36 USE mpipara, ONLY : is_mpi_master 37 IF(is_mpi_master) PRINT *, 'phyparam/physics called' 73 USE mpipara, ONLY : is_mpi_master 74 USE icosa, ONLY : llm 75 USE physics_interface_mod, ONLY : inout => physics_inout 76 USE phyparam_mod 77 USE error_mod 78 REAL :: dps(inout%ngrid), play(inout%ngrid, llm), pphi(inout%ngrid, llm) 79 REAL :: timestep, time, jourvrai, gmtime 80 INTEGER :: l 81 IF(is_mpi_master) WRITE(log_unit,*) 'phyparam/physics called', SHAPE(inout%p), SHAPE(inout%pk) 82 83 timestep = inout%dt_phys 84 time = timestep * inout%it 85 gmtime = time/oneday 86 jourvrai = FLOOR(gmtime) 87 gmtime = gmtime - jourvrai 88 89 ! compute pressure and geopotential at full levels 90 CALL compute_play(inout%ngrid, llm, inout%p, play) 91 CALL compute_play(inout%ngrid, llm, inout%geopot, pphi) 92 93 ! substract surface geopotential 94 DO l=1,llm 95 pphi(:,l) = pphi(:,l) - inout%geopot(:,1) 96 END DO 97 98 IF(is_mpi_master) PRINT *, 'phyparam phi :', pphi(inout%ngrid/2+1, :) 99 100 CALL check_NaN('physics', 'ulon', inout%ulon) 101 CALL check_NaN('physics', 'ulat', inout%ulat) 102 CALL check_NaN('physics', 'temp', inout%temp) 103 104 ! go 105 CALL phyparam(inout%ngrid,llm, & 106 & firstcall,lastcall, & 107 & jourvrai, gmtime, timestep, & 108 & inout%p, play, pphi, & 109 & inout%ulon, inout%ulat, inout%temp, & 110 & inout%dulon, inout%dulat, inout%dtemp, dps) 111 112 IF(is_mpi_master) PRINT *, 'phyparam dT :', inout%dtemp(inout%ngrid/2+1, :) 113 114 CALL check_NaN('physics', 'dulon', inout%dulon) 115 CALL check_NaN('physics', 'dulat', inout%dulat) 116 CALL check_NaN('physics', 'dtemp', inout%dtemp) 117 118 firstcall = .FALSE. 38 119 END SUBROUTINE physics 39 120 121 SUBROUTINE compute_play(ngrid, llm, plev, play) 122 INTEGER, INTENT(IN) :: ngrid, llm 123 REAL, INTENT(IN) :: plev(ngrid, llm+1) ! pressure at interfaces (half-levels) 124 REAL, INTENT(OUT) :: play(ngrid, llm) ! pressure in layers (full levels) 125 INTEGER :: ij, l 126 DO l = 1,llm 127 DO ij = 1,ngrid 128 play(ij,l) = .5*(plev(ij,l)+plev(ij,l+1)) 129 END DO 130 END DO 131 END SUBROUTINE compute_play 132 133 !------------------------------------------------------------------------------------ 134 !------------------------------- Infrastructure plugins ----------------------------- 135 136 !--------------------------------------- Logging ------------------------------------ 137 138 SUBROUTINE flush_log_(lev, tag, buf) 139 USE mpipara, ONLY : is_mpi_master 140 USE logging, ONLY : dbtag 141 INTEGER, INTENT(IN) :: lev 142 CHARACTER(*), INTENT(IN) :: tag, buf(:) 143 CHARACTER(100) :: prefix 144 INTEGER :: i 145 146 IF(is_mpi_master) THEN 147 WRITE(prefix,*) '[', dbtag(lev), ' ', tag, ']' 148 DO i=1, SIZE(buf) 149 WRITE(log_unit,*) TRIM(prefix), TRIM(buf(i)) 150 END DO 151 WRITE(log_unit, *) '' 152 END IF 153 END SUBROUTINE flush_log_ 154 155 !--------------------------------------- read_param ------------------------------------ 156 157 SUBROUTINE read_paramr(name, defval, val, comment) 158 USE getin_mod, ONLY : getin 159 CHARACTER(*), INTENT(IN) :: name, comment 160 REAL, INTENT(IN) :: defval 161 REAL, INTENT(OUT) :: val 162 val = defval 163 CALL getin(name, val) 164 END SUBROUTINE read_paramr 165 166 SUBROUTINE read_parami(name, defval, val, comment) 167 USE getin_mod, ONLY : getin 168 CHARACTER(*), INTENT(IN) :: name, comment 169 INTEGER, INTENT(IN) :: defval 170 INTEGER, INTENT(OUT) :: val 171 val = defval 172 CALL getin(name, val) 173 END SUBROUTINE read_parami 174 175 SUBROUTINE read_paramb(name, defval, val, comment) 176 USE getin_mod, ONLY : getin 177 CHARACTER(*), INTENT(IN) :: name, comment 178 LOGICAL, INTENT(IN) :: defval 179 LOGICAL, INTENT(OUT) :: val 180 val = defval 181 CALL getin(name, val) 182 END SUBROUTINE read_paramb 183 40 184 END MODULE icosa_phyparam_mod
Note: See TracChangeset
for help on using the changeset viewer.