Changeset 757 for trunk/LMDZ.MARS/libf/phymars/nlte_aux.F
- Timestamp:
- Aug 7, 2012, 3:14:07 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/libf/phymars/nlte_aux.F
r695 r757 1 c********************************************************************** 2 3 c Includes the following old 1-D model files/subroutines 4 5 c -MZTCRSUB_dlvr11.f 6 c *dinterconnection 7 c *planckd 8 c *leetvt 9 c -MZTFSUB_dlvr11_02.f 10 c *initial 11 c *intershphunt 12 c *interstrhunt 13 c *intzhunt 14 c *intzhunt_cts 15 c *rhist 16 c *we_clean 17 c *mztf_correccion 18 c *mzescape_normaliz 19 c *mzescape_normaliz_02 20 c -interdpESCTVCISO_dlvr11.f 21 c -hunt_cts.f 22 c -huntdp.f 23 c -hunt.f 24 c -interdp_limits.f 25 c -interhunt2veces.f 26 c -interhunt5veces.f 27 c -interhuntdp3veces.f 28 c -interhuntdp4veces.f 29 c -interhuntdp.f 30 c -interhunt.f 31 c -interhuntlimits2veces.f 32 c -interhuntlimits5veces.f 33 c -interhuntlimits.f 34 c -lubksb_dp.f 35 c -ludcmp_dp.f 36 c -LUdec.f 37 c -mat_oper.f 38 c *unit 39 c *diago 40 c *invdiag 41 c *samem 42 c *mulmv 43 c *trucodiag 44 c *trucommvv 45 c *sypvmv 46 c *mulmm 47 c *resmm 48 c *sumvv 49 c *sypvvv 50 c *zerom 51 c *zero4m 52 c *zero3m 53 c *zero2m 54 c *zerov 55 c *zero4v 56 c *zero3v 57 c *zero2v 58 c -suaviza.f 59 60 c********************************************************************** 61 62 63 c *** Old MZTCRSUB_dlvr11.f *** 64 65 !************************************************************************ 66 67 ! subroutine dinterconnection ( v, vt ) 68 69 70 ************************************************************************ 71 72 ! implicit none 73 ! include 'nlte_paramdef.h' 74 75 c argumentos 76 ! real*8 vt(nl), v(nl) 77 78 c local variables 79 ! integer i 80 81 c ************* 82 ! 83 ! do i=1,nl 84 ! v(i) = vt(i) 85 ! end do 86 87 ! return 88 ! end 89 1 90 c*********************************************************************** 2 c File with all subroutines required by mztf 3 c Subroutines previously included in mztfsub_overlap.F 4 c 5 c jan 98 malv basado en mztfsub_solar 6 c jul 2011 malv+fgg adapted to LMD-MGCM 7 c 8 c contiene: 9 c initial 10 c intershape 11 c interstrength 12 c intz 13 c rhist 14 c we 15 c simrul 16 c fi 17 c f 18 c findw 19 c voigtf 91 function planckdp(tp,xnu) 20 92 c*********************************************************************** 21 22 c **************************************************************** 23 subroutine initial 24 25 c ma & crs !evita troubles 16-july-96 26 c **************************************************************** 27 28 implicit none 29 93 94 implicit none 95 96 include 'nlte_paramdef.h' 97 98 real*8 planckdp 99 real*8 xnu 100 real tp 101 102 planckdp = gamma*xnu**3.0d0 / exp( ee*xnu/dble(tp) ) 103 !erg cm-2.sr-1/cm-1. 104 105 c end 106 return 107 end 108 109 c*********************************************************************** 110 subroutine leetvt 111 112 c*********************************************************************** 113 114 implicit none 115 30 116 include 'nlte_paramdef.h' 31 117 include 'nlte_commons.h' 32 33 c local variables 34 integer i 35 36 c *************** 37 38 eqw = 0.0d00 39 aa = 0.0d00 40 bb = 0.0d00 41 cc = 0.0d00 42 dd = 0.0d00 43 44 do i=1,nbox 45 ua(i) = 0.0d0 46 ccbox(i) = 0.0d0 47 ddbox(i) = 0.0d0 48 end do 49 50 return 51 end 52 53 c ********************************************************************** 54 subroutine intershape(alsx,alnx,adx,xtemp) 55 c interpolates the line shape parameters at a temperature xtemp from 56 c input histogram data. 57 c ********************************************************************** 58 59 implicit none 60 118 119 c local variables 120 integer i 121 real*8 zld(nl), zyd(nzy) 122 real*8 xvt11(nzy), xvt21(nzy), xvt31(nzy), xvt41(nzy) 123 124 c*********************************************************************** 125 126 do i=1,nzy 127 zyd(i) = dble(zy(i)) 128 xvt11(i)= dble( ty(i) ) 129 xvt21(i)= dble( ty(i) ) 130 xvt31(i)= dble( ty(i) ) 131 xvt41(i)= dble( ty(i) ) 132 end do 133 134 do i=1,nl 135 zld(i) = dble( zl(i) ) 136 enddo 137 call interhuntdp4veces ( v626t1,v628t1,v636t1,v627t1, zld,nl, 138 $ xvt11, xvt21, xvt31, xvt41, zyd,nzy, 1 ) 139 140 141 c end 142 return 143 end 144 145 146 c *** MZTFSUB_dlvr11_02.f *** 147 148 149 c **************************************************************** 150 subroutine initial 151 152 c **************************************************************** 153 154 implicit none 155 61 156 include 'nlte_paramdef.h' 62 157 include 'nlte_commons.h' 63 64 c arguments 65 real*8 alsx(nbox_max),alnx(nbox_max),adx(nbox_max), 66 & xtemp(nbox_max) 67 68 c local variables 69 integer i, k 70 71 c *********** 72 73 ! write (*,*) 'intershape xtemp =', xtemp 74 75 do 1, k=1,nbox 76 if (xtemp(k).gt.tmax) then 77 write (*,*) ' WARNING ! Tpath,tmax= ',xtemp(k),tmax 78 xtemp(k) = tmax 79 endif 80 if (xtemp(k).lt.tmin) then 81 write (*,*) ' WARNING ! Tpath,tmin= ',xtemp(k),tmin 82 xtemp(k) = tmin 83 endif 84 85 i = 1 86 do while (i.le.mm) 87 i = i + 1 88 89 if (abs(xtemp(k)-thist(i)) .lt. 1.0d-4) then !evita troubles 90 alsx(k)=xls1(i,k) !16-july-1996 91 alnx(k)=xln1(i,k) 92 adx(k)=xld1(i,k) 93 goto 1 94 elseif ( thist(i) .le. xtemp(k) ) then 95 alsx(k) = (( xls1(i,k)*(thist(i-1)-xtemp(k)) + 96 @ xls1(i-1,k)*(xtemp(k)-thist(i)) )) / 97 $ (thist(i-1)-thist(i)) 98 alnx(k) = (( xln1(i,k)*(thist(i-1)-xtemp(k)) + 99 @ xln1(i-1,k)*(xtemp(k)-thist(i)) )) / 100 $ (thist(i-1)-thist(i)) 101 adx(k) = (( xld1(i,k)*(thist(i-1)-xtemp(k)) + 102 @ xld1(i-1,k)*(xtemp(k)-thist(i)) )) / 103 $ (thist(i-1)-thist(i)) 104 goto 1 105 end if 106 end do 107 write (*,*) 108 @ ' error in xtemp(k). it should be between tmin and tmax' 109 1 continue 110 111 return 112 end 158 159 c local variables 160 integer i 161 162 c *************** 163 164 eqw = 0.0d00 165 aa = 0.0d00 166 cc = 0.0d00 167 dd = 0.0d00 168 169 do i=1,nbox 170 ccbox(i) = 0.0d0 171 ddbox(i) = 0.0d0 172 end do 173 174 return 175 end 176 113 177 c ********************************************************************** 114 subroutine interstrength (stx, ts, sx, xtemp) 115 c interpolates the line strength at a temperature xtemp from 116 c input histogram data. 178 179 subroutine intershphunt (i, alsx,adx,xtemp) 180 117 181 c ********************************************************************** 118 119 implicit none 120 182 183 implicit none 184 121 185 include 'nlte_paramdef.h' 122 186 include 'nlte_commons.h' 123 124 c arguments 125 real*8 stx ! output, total band strength 126 real*8 ts ! input, temp for stx 127 real*8 sx(nbox_max) ! output, strength for each box 128 real*8 xtemp(nbox_max) ! input, temp for sx 129 130 c local variables 131 integer i, k 132 133 c *********** 134 135 do 1, k=1,nbox 136 ! if(xtemp(k).lt.ts)then 137 ! write(*,*)'***********************' 138 ! write(*,*)'mztfsub_overlap/EEEEEEH!',xtemp(k),ts,k 139 ! write(*,*)'***********************' 140 ! endif 141 if (xtemp(k).gt.tmax) xtemp(k) = tmax 142 if (xtemp(k).lt.tmin) xtemp(k) = tmin 143 i = 1 144 do while (i.le.mm-1) 145 i = i + 1 146 ! write(*,*)'mztfsub_overlap/136',i,xtemp(k),thist(i) 147 if ( abs(xtemp(k)-thist(i)) .lt. 1.0d-4 ) then 148 sx(k) = sk1(i,k) 149 ! write(*,*)'mztfsub_overlap/139',sx(k),k,i 150 goto 1 151 elseif ( thist(i) .le. xtemp(k) ) then 152 sx(k) = ( sk1(i,k)*(thist(i-1)-xtemp(k)) + sk1(i-1,k)* 153 @ (xtemp(k)-thist(i)) ) / (thist(i-1)-thist(i)) 154 ! write(*,*)'mztfsub_overlap/144',sx(k),k,i 155 goto 1 156 end if 157 end do 158 write (*,*) ' error in xtemp(kr) =', xtemp(k), 159 @ '. it should be between ' 160 write (*,*) ' tmin =',tmin, ' and tmax =',tmax 161 stop 162 1 continue 163 164 stx = 0.d0 165 if (ts.gt.tmax) ts = dble( tmax ) 166 if (ts.lt.tmin) ts = dble( tmin ) 167 i = 1 168 do while (i.le.mm-1) 169 i = i + 1 170 ! write(*,*)'mztfsub_overlap/160',i,ts,thist(i) 171 if ( abs(ts-thist(i)) .lt. 1.0d-4 ) then 172 do k=1,nbox 173 stx = stx + no(k) * sk1(i,k) 174 ! write(*,*)'mztfsub_overlap/164',stx 175 end do 176 return 177 elseif ( thist(i) .le. ts ) then 178 do k=1,nbox 179 stx = stx + no(k) * (( sk1(i,k)*(thist(i-1)-ts) + 180 @ sk1(i-1,k)*(ts-thist(i)) )) / (thist(i-1)-thist(i)) 181 ! write(*,*)'mztfsub_overlap/171',stx 182 end do 183 ! stop 184 return 185 end if 186 end do 187 188 return 189 end 190 191 187 188 c arguments 189 real*8 alsx(nbox_max),adx(nbox_max) ! Output 190 real*8 xtemp(nbox_max) ! Input 191 integer i ! I , O 192 193 c local variables 194 integer k 195 real*8 factor 196 real*8 temperatura ! para evitar valores ligeramnt out of limits 197 198 c *********** 199 200 do 1, k=1,nbox_max 201 temperatura = xtemp(k) 202 if (abs(xtemp(k)-thist(1)).le.0.01d0) then 203 temperatura=thist(1) 204 elseif (abs(xtemp(k)-thist(nhist)).le.0.01d0) then 205 temperatura=thist(nhist) 206 endif 207 call huntdp ( thist,nhist, temperatura, i ) 208 if ( i.eq.0 .or. i.eq.nhist ) then 209 write (*,*) ' HUNT/ Limits input grid:', 210 @ thist(1),thist(nhist) 211 write (*,*) ' HUNT/ location in new grid:', xtemp(k) 212 stop ' INTERSHP/ Interpolation error. T out of Histogram.' 213 endif 214 factor = 1.d0 / (thist(i+1)-thist(i)) 215 alsx(k) = (( xls1(i,k)*(thist(i+1)-xtemp(k)) + 216 @ xls1(i+1,k)*(xtemp(k)-thist(i)) )) * factor 217 adx(k) = (( xld1(i,k)*(thist(i+1)-xtemp(k)) + 218 @ xld1(i+1,k)*(xtemp(k)-thist(i)) )) * factor 219 1 continue 220 221 return 222 end 223 192 224 c ********************************************************************** 193 subroutine intz(h,aco2,ap,amr,at, con) 194 c return interp. concentration, pressure,mixing ratio and temperature 195 c for a input height h 225 226 subroutine interstrhunt (i, stx, ts, sx, xtemp ) 227 196 228 c ********************************************************************** 197 198 implicit none 229 230 implicit none 231 199 232 include 'nlte_paramdef.h' 200 233 include 'nlte_commons.h' 201 202 c arguments 203 real h ! i 204 real*8 con(nzy) ! i 205 real*8 aco2, ap, at, amr ! o 206 207 c local variables 208 integer k 209 210 c ************ 211 212 if ( ( h.lt.zy(1) ).and.( h.le.-1.e-5 ) ) then 213 write (*,*) ' zp= ',h,' zy(1)= ',zy(1) 214 stop'from intz: error in interpolation, z < minimum height' 215 elseif (h.gt.zy(nzy)) then 216 write (*,*) ' zp= ',h,' zy(nzy)= ',zy(nzy) 217 stop'from intz: error in interpolation, z > maximum height' 218 end if 219 220 if (h.eq.zy(nzy)) then 221 ap = dble( py(nzy) ) 222 aco2= con(nzy) 223 at = dble( ty(nzy) ) 224 amr = dble( mr(nzy) ) 225 return 226 end if 227 228 do k=1,nzy-1 229 if( abs( h-zy(k) ).le.( 1.e-5 ) ) then 230 ap = dble( py(k) ) 231 aco2= con(k) 232 at = dble( ty(k) ) 233 amr = dble( mr(k) ) 234 return 235 elseif(h.gt.zy(k).and.h.lt.zy(k+1))then 236 ap = dble( exp( log(py(k)) + log(py(k+1)/py(k)) * 237 @ (h-zy(k)) / (zy(k+1)-zy(k)) ) ) 238 aco2 = exp( log(con(k)) + log( con(k+1)/con(k) ) * 239 @ (h-zy(k)) / (zy(k+1)-zy(k)) ) 240 at = dble( ty(k)+(ty(k+1)-ty(k))*(h-zy(k))/ 241 @ (zy(k+1)-zy(k)) ) 242 amr = dble( mr(k)+(mr(k+1)-mr(k))*(h-zy(k))/ 243 @ (zy(k+1)-zy(k)) ) 244 return 245 end if 246 end do 247 248 return 249 end 250 251 252 234 235 c arguments 236 real*8 stx ! output, total band strength 237 real*8 ts ! input, temp for stx 238 real*8 sx(nbox_max) ! output, strength for each box 239 real*8 xtemp(nbox_max) ! input, temp for sx 240 integer i 241 242 c local variables 243 integer k 244 real*8 factor 245 real*8 temperatura 246 247 c *********** 248 249 do 1, k=1,nbox 250 temperatura = xtemp(k) 251 if (abs(xtemp(k)-thist(1)).le.0.01d0) then 252 temperatura=thist(1) 253 elseif (abs(xtemp(k)-thist(nhist)).le.0.01d0) then 254 temperatura=thist(nhist) 255 endif 256 call huntdp ( thist,nhist, temperatura, i ) 257 if ( i.eq.0 .or. i.eq.nhist ) then 258 write(*,*)'HUNT/ Limits input grid:',thist(1),thist(nhist) 259 write(*,*)'HUNT/ location in new grid:',xtemp(k) 260 stop'INTERSTR/1/ Interpolation error. T out of Histogram.' 261 endif 262 factor = 1.d0 / (thist(i+1)-thist(i)) 263 sx(k) = ( sk1(i,k) * (thist(i+1)-xtemp(k)) 264 @ + sk1(i+1,k) * (xtemp(k)-thist(i)) ) * factor 265 1 continue 266 267 268 temperatura = ts 269 if (abs(ts-thist(1)).le.0.01d0) then 270 temperatura=thist(1) 271 elseif (abs(ts-thist(nhist)).le.0.01d0) then 272 temperatura=thist(nhist) 273 endif 274 call huntdp ( thist,nhist, temperatura, i ) 275 if ( i.eq.0 .or. i.eq.nhist ) then 276 write (*,*) ' HUNT/ Limits input grid:', 277 @ thist(1),thist(nhist) 278 write (*,*) ' HUNT/ location in new grid:', ts 279 stop ' INTERSTR/2/ Interpolat error. T out of Histogram.' 280 endif 281 factor = 1.d0 / (thist(i+1)-thist(i)) 282 stx = 0.d0 283 do k=1,nbox 284 stx = stx + no(k) * ( sk1(i,k)*(thist(i+1)-ts) + 285 @ sk1(i+1,k)*(ts-thist(i)) ) * factor 286 end do 287 288 289 return 290 end 291 253 292 c ********************************************************************** 254 real*8 function iaa_we(ig,me,pe,plaux,idummy,nt_local,p_local, 255 $ Desp,wsL) 256 c icls=5 -->para mztf 257 c icls=1,2,3-->para fot, line shape (v=1,l=2,d=3) (only use if wr=2) 258 c calculates an approximate equivalent width for an error estimate. 259 c 260 c ioverlap = 0 ....... no correction for overlaping 261 c 1 ....... "lisat" first correction (see overlap_box. 262 c 2 ....... " " " plus "supersaturation" 263 264 c idummy=0 do nothing 265 c 1 write out some values for diagnostics 266 c 2 correct the Strong Lorentz behaviour for SZA>90 267 c 3 casos 1 & 2 268 269 c malv nov-98 add overlaping's corrections 293 294 subroutine intzhunt (k, h, aco2,ap,amr,at, con) 295 296 c k lleva la posicion de la ultima llamada a intz , necesario para 297 c que esto represente una aceleracion real. 270 298 c ********************************************************************** 271 272 implicit none 273 299 300 implicit none 274 301 include 'nlte_paramdef.h' 275 302 include 'nlte_commons.h' 276 277 c arguments 278 integer ig ! ADDED FOR TRACEBACK 279 real*8 me ! I. path's absorber amount 280 real*8 pe ! I. path's presion total 281 real*8 plaux ! I. path's partial pressure of CO2 282 real*8 nt_local ! I. needed for strong limit of Lorentz profil 283 real*8 p_local ! I. " " " 284 integer idummy ! I. indica varias opciones 285 real*8 wsL ! O. need this for strong Lorentz correction 286 real*8 Desp ! I. need this for strong Lorentz correction 287 288 c local variables 289 integer i 290 real*8 y,x,wl,wd 291 real*8 cn(0:7),dn(0:7) 292 real*8 pi, xx 293 real*8 f_sat_box 294 real*8 dv_sat_box, dv_corte_box 295 real*8 area_core_box, area_wing_box 296 real*8 wlgood , parentesis , xlor 297 real*8 wsl_grad 298 299 300 c data blocks 301 data cn/9.99998291698d-1,-3.53508187098d-1,9.60267807976d-2, 302 @ -2.04969011013d-2,3.43927368627d-3,-4.27593051557d-4, 303 @ 3.42209457833d-5,-1.28380804108d-6/ 304 data dn/1.99999898289,5.774919878d-1,-5.05367549898d-1, 305 @ 8.21896973657d-1,-2.5222672453,6.1007027481, 306 @ -8.51001627836,4.6535116765/ 307 308 c *********** 309 310 c equivalent width of atmospheric line. 311 312 pi = acos(-1.d0) 313 314 if ( idummy.gt.9 ) 315 @ write (*,*) ' S, m, alsa, pp =', ka(kr), me, alsa(kr), plaux 316 317 y=ka(kr)*me 318 ! x=y/(2.0*pi*(alsa(kr)*pl+alna(kr)*(pe-pl))) 319 x=y/(2.0d0*pi* alsa(kr)*plaux) !+alna(kr)*(pe-pl))) 320 321 ! Strong limit of Lorentz profile: WL = 2 SQRT( S * m * alsa*pl ) 322 ! Para anular esto, comentar las siguientes 5 lineas 323 ! if ( x .gt. 1.e6 ) then 324 ! wl = 2.0*sqrt( y * alsa(kr)*pl ) 325 ! else 326 ! wl=y/sqrt(1.0d0+pi*x/2.0d0) 327 ! endif 328 329 wl=y/sqrt(1.0d0+pi*x/2.0d0) 330 331 if (wl .le. 0.d0) then 332 write(*,*)'mztfsub_overlap/496',ig,y,ka(kr),me,kr 333 stop'WE/Lorentz EQW zero or negative!/498' !,ig 334 endif 335 336 if ( idummy.gt.9 ) 337 @ write (*,*) ' y, x =', y, x 338 339 xlor = x 340 if ( (idummy.eq.2 .or. idummy.eq.12) .and. xlor.gt.1e5 ) then 341 ! en caso que estemos en el regimen 342 ! Strong Lorentz y la presion local 343 ! vaya disminuyendo, corregimos la EQW 344 ! con un gradiente analitico (notebook) 345 wsL = 2.0*sqrt( y * alsa(kr)*plaux ) 346 wsl_grad = - 2.d0 * ka(kr)*alsa(kr) * nt_local*p_local / wsL 347 wlgood = w_strongLor_prev(kr) + wsl_grad * Desp 348 if (idummy.eq.12) 349 @ write (*,*) ' W(wrong), W_SL, W_SL prev, W_SL corrected=', 350 @ wl, wsL, w_strongLor_prev(kr), wlgood 351 wl = wlgood 352 endif 353 ! wsL = wl pero esto no lo hacemos todavia, porque necesitamos 354 ! el valor que ahora mismo tiene wsL para corregir la 355 ! expresion R&W below 356 357 ! write (*,*) 'WE arguments me,pe,pl =', me,pe,pl 358 ! write (*,*) 'WE/ wl,ka(kr),alsa(kr) =', 359 ! @ wl, ka(kr),alsa(kr) 360 361 362 !>>>>>>> 363 500 format (a,i3,3(2x,1pe15.8)) 364 600 format (a,2(2x,1pe16.9)) 365 700 format (a,3(1x,1pe16.9)) 366 ! if (kr.eq.8 .or. kr.eq.13) then 367 ! write (*,500) 'WE/kr,m,pt,pl=', kr, me, pe, pl 368 ! write (*,700) ' /aln,als,d_x=', alna(kr),alsa(kr), 369 ! @ 2.0*pi*( alsa(kr)*pl + alna(kr)*(pe-pl) ) 370 ! write (*,600) ' /alsa*p_CO2, alna*p_n2 :', 371 ! @ alsa(kr)*pl, alna(kr)*(pe-pl) 372 ! write (*,600) ' a*p, S =', 373 ! @ alsa(kr)*pl + alna(kr)*(pe-pl) , ka(kr) 374 ! write (*,600) ' /S*m, x =', y, x 375 ! write (*,600) ' /aprox, WL =', 376 ! @ 2.*sqrt( y*( alsa(kr)*pl+alna(kr)*(pe-pl) ) ), WL 377 ! endif 378 ! 379 ! corrections to lorentz eqw due to overlaping and super-saturation 380 ! 381 382 i_supersat = 0 383 384 if ( icls.eq.5 .and. ioverlap.gt.0 ) then 385 ! for the moment, only consider overlaping for mztf.f, not fot.f 386 387 ! definition of saturation in the lisat model 388 ! 389 asat_box = 0.99d0 390 f_sat_box = 2.d0 * x 391 xx = f_sat_box / log( 1./(1-asat_box) ) 392 if ( xx .lt. 1.0d0 ) then 393 dv_sat_box = 0.0d0 394 asat_box = 1.0d0 - exp( - f_sat_box ) 395 else 396 dv_sat_box = alsa(kr) * sqrt( xx - 1.0d0 ) 397 ! approximation: only use of alsa in mars and venus 398 endif 399 400 ! area of saturated line 401 ! 402 area_core_box = 2.d0 * dv_sat_box * asat_box 403 area_wing_box = 0.5d0 * ( wl - area_core_box ) 404 dv_corte_box = dv_sat_box + 2.d0*area_wing_box/asat_box 405 406 ! super-saturation or simple overlaping? 407 ! 408 ! i_supersat = 0 409 xx = dv_sat_box - ( 0.5d0 * dist(kr) ) 410 if ( xx .ge. 0.0 ! definition of supersaturation 411 @ .and. dv_sat_box .gt. 0.0 ! definition of saturation 412 @ .and. (dist(kr).gt.0.0) ) ! box contains more than 1 line 413 @ ! and not too far apart 414 @ then 415 416 i_supersat = 1 417 418 else 419 ! no super-saturation, then use "lisat + first correction", i.e., 420 ! correct for line products 421 ! 422 423 wl = wl 424 425 endif 426 427 end if ! end of overlaping loop 428 429 if (icls.eq.2) then 430 iaa_we = wl 431 return 432 endif 433 434 cc doppler limit: 435 if ( idummy.gt.9 ) 436 @ write (*,*) ' S*m, alf_dop =', y, alda(kr)*sqrt(pi) 437 438 x = y / (alda(kr)*sqrt(pi)) 439 if ( x.lt.1.e-10 ) then ! to avoid underflow 440 wd = y 441 else 442 wd=alda(kr)*sqrt(4.0*pi*x**2*(1.0+log(1.0+x))/(4.0+pi*x**2)) 443 endif 444 if ( idummy.gt.9 ) 445 @ write (*,*) ' wd =', wd 446 447 cc doppler weak limit 448 c wd = ka(kr) * me 449 450 cc good doppler 451 if(icls.eq.5) then !para mztf 452 !write (*,*) 'para mztf, icls=',icls 453 if (x.lt.5.) then 454 wd = 0.d0 455 do i=0,7 456 wd = wd + cn(i) * x**i 457 end do 458 wd = alda(kr) * x * sqrt(pi) * wd 459 elseif (x.gt.5.) then 460 wd = 0.d0 461 do i=0,7 462 wd = wd + dn(i) / (log(x))**i 463 end do 464 wd = alda(kr) * sqrt(log(x)) * wd 465 else 466 stop ' x should not be less than zero' 467 end if 468 end if 469 470 471 if ( i_supersat .eq. 0 ) then 472 473 parentesis = wl**2+wd**2-(wd*wl/y)**2 474 ! changed +(wd*wl/y)**2 to -...14-3-84 475 476 if ( parentesis .lt. 0.0 ) then 477 if ((idummy.eq.2 .or. idummy.eq.12) .and. xlor.gt.1e5) then 478 parentesis = wl**2+wd**2-(wd*wsL/y)**2 479 ! este cambio puede ser necesario cuando se hace 480 ! correccion Strong Lor, para evitar valores 481 ! negativos del parentesis en sqrt( ) 482 else 483 stop ' WE/ Error en las EQW wl,wl,y ' 484 endif 485 endif 486 487 iaa_we = sqrt( parentesis ) 488 ! write (*,*) ' from iaa_we: xdop,alda,wd', sngl(x),alda(kr),sngl(wd) 489 ! write (*,*) ' from iaa_we: we', iaa_we 490 491 else 492 493 iaa_we = wl 494 ! if there is supersaturation we can ignore wd completely; 495 ! mztf.f will compute the eqw of the whole box afterwards 496 497 endif 498 499 if (icls.eq.3) iaa_we = wd 500 501 if ( idummy.gt.9 ) 502 @ write (*,*) ' wl,wd,w =', wl,wd,iaa_we 503 504 wsL = wl 505 506 return 507 end 508 509 303 304 c arguments 305 real h ! i 306 real*8 con(nzy) ! i 307 real*8 aco2, ap, at, amr ! o 308 integer k ! i 309 310 c local variables 311 real factor 312 313 c ************ 314 315 call hunt ( zy,nzy, h, k ) 316 factor = (h-zy(k)) / (zy(k+1)-zy(k)) 317 ap = dble( exp( log(py(k)) + log(py(k+1)/py(k)) * factor ) ) 318 aco2 = dlog(con(k)) + dlog( con(k+1)/con(k) ) * dble(factor) 319 aco2 = exp( aco2 ) 320 at = dble( ty(k) + (ty(k+1)-ty(k)) * factor ) 321 amr = dble( mr(k) + (mr(k+1)-mr(k)) * factor ) 322 323 324 return 325 end 326 510 327 c ********************************************************************** 511 real*8 function simrul(a,b,fsim,c,acc) 512 c adaptively integrates fsim from a to b, within the criterion acc. 328 329 subroutine intzhunt_cts (k, h, nzy_cts_real, 330 @ aco2,ap,amr,at, con) 331 332 c k lleva la posicion de la ultima llamada a intz , necesario para 333 c que esto represente una aceleracion real. 513 334 c ********************************************************************** 514 515 implicit none 516 517 real*8 res,a,b,g0,g1,g2,g3,g4,d,a0,a1,a2,h,x,acc,c,fsim 518 real*8 s1(70),s2(70),s3(70) 519 real*8 c1, c2 520 integer*4 m,n,j 521 522 res=0. 523 c=0. 524 m=0 525 n=0 526 j=30 527 g0=fsim(a) 528 g2=fsim((a+b)/2.) 529 g4=fsim(b) 530 a0=(b-a)*(g0+4.0*g2+g4)/2.0 531 1 d=2.0**n 532 h=(b-a)/(4.0*d) 533 x=a+(4.0*m+1.0)*h 534 g1=fsim(x) 535 g3=fsim(x+2.0*h) 536 a1=h*(g0+4.0*g1+g2) 537 a2=h*(g2+4.0*g3+g4) 538 if ( abs(a1+a2-a0).gt.(acc/d)) goto 2 539 res=res+(16.0*(a1+a2)-a0)/45.0 540 m=m+1 541 c=a+m*(b-a)/d 542 6 if (m.eq.(2*(m/2))) goto 4 543 if ((m.ne.1).or.(n.ne.0)) goto 5 544 8 simrul=res 545 return 546 2 m=2*m 547 n=n+1 548 if (n.gt.j) goto 3 549 a0=a1 550 s1(n)=a2 551 s2(n)=g3 552 s3(n)=g4 553 g4=g2 554 g2=g1 555 goto 1 556 3 c1=c-(b-a)/d 557 c2=c+(b-a)/d 558 write(2,7) c1,c,c2,fsim(c1),fsim(c),fsim(c2) 559 write(*,7) c1,c,c2,fsim(c1),fsim(c),fsim(c2) 560 7 format(2x,'17hsimrule fails at ',/,3e15.6,/,3e15.6) 561 goto 8 562 5 a0=s1(n) 563 g0=g4 564 g2=s2(n) 565 g4=s3(n) 566 goto 1 567 4 m=m/2 568 n=n-1 569 goto 6 570 end 571 572 c ********************************************************************** 573 subroutine findw(ig,iirw,idummy,c1,p1, Desp, wsL) 574 c this routine sets up accuracy criteria and calls simrule between limit 575 c that depend on the number of atmospheric and cell paths. it gives eqw. 576 577 c Add correction for EQW in Strong Lorentz regime and SZA>90 578 c ********************************************************************** 579 580 implicit none 335 336 implicit none 581 337 include 'nlte_paramdef.h' 582 338 include 'nlte_commons.h' 583 584 c arguments 585 integer ig ! ADDED FOR TRACEBACK 586 integer iirw 587 integer idummy ! I. indica varias opciones 588 real*8 c1 ! I. needed for strong limit of Lorentz profil 589 real*8 p1 ! I. " " " 590 real*8 wsL ! O. need this for strong Lorentz correction 591 real*8 Desp ! I. need this for strong Lorentz correction 592 593 c local variables 594 real*8 ept,eps,xa 595 real*8 acc, c 596 real*8 iaa_we 597 real*8 iaa_f, iaa_fi, simrul 598 599 external iaa_f,iaa_fi 600 601 c ********** *********** ********* 602 603 if(icls.eq.5) then !para mztf 604 ! if(ig.eq.1682)write(*,*)'mztfsub_overlap/768',ua(kr),iirw 605 if (iirw.eq.2) then !iirw=icf=2 ==> we use the w&r formula 606 w = iaa_we(ig,ua(kr),pt,pp, idummy, c1,p1, Desp, wsL ) 607 return 608 end if 609 ept=iaa_we(ig,ua(kr),pt,pp, idummy,c1,p1, Desp, wsL) 610 else !para fot 611 if (iirw.eq.2) then ! icf=2 ==> we use the w&r formula 612 w = iaa_we(ig,sl_ua,pt,pp, idummy,c1,p1, Desp, wsL) 613 return 614 end if 615 ept=iaa_we(ig,sl_ua,pt,pp, idummy,c1,p1, Desp, wsL) 616 end if 617 618 c the next block is a modification to avoid nul we. 619 c this situation appears for weak lines and low path temperature, but 620 c there is not any loss of accuracy. first july 1986 621 if (ept.eq.0.) then ! for weak lines sometimes we=0 622 ept=1.0e-18 623 write (*,*) 'ept =',ept 624 write (*,*) 'from we: we=0.0' 625 return 626 end if 627 628 acc = 4.d0 629 acc = 10.d0**(-acc) 630 631 eps = acc * ept !accuracy 10-4 atmospheric eqw. 632 xa=0.5*ept/iaa_f(0.d0) !width of doppler shifted atmospheric line. 633 w = 2.0*( simrul(0.0d0,xa,iaa_f,c,eps) 634 . + simrul(0.1d0,1.0/xa,iaa_fi,c,eps) ) 635 !no shift. 636 637 return 638 end 639 640 339 340 c arguments 341 real h ! i 342 real*8 con(nzy_cts) ! i 343 real*8 aco2, ap, at, amr ! o 344 integer k ! i 345 integer nzy_cts_real ! i 346 347 c local variables 348 real factor 349 350 c ************ 351 352 call hunt_cts ( zy_cts,nzy_cts, nzy_cts_real, h, k ) 353 factor = (h-zy_cts(k)) / (zy_cts(k+1)-zy_cts(k)) 354 ap = dble( exp( log(py_cts(k)) + 355 @ log(py_cts(k+1)/py_cts(k)) * factor ) ) 356 aco2 = dlog(con(k)) + dlog( con(k+1)/con(k) ) * dble(factor) 357 aco2 = exp( aco2 ) 358 at = dble( ty_cts(k) + (ty_cts(k+1)-ty_cts(k)) * factor ) 359 amr = dble( mr_cts(k) + (mr_cts(k+1)-mr_cts(k)) * factor ) 360 361 362 return 363 end 364 365 641 366 c ********************************************************************** 642 double precision function iaa_fi(y) 643 c returns the value of f(1/y) 367 368 real*8 function we_clean ( y,pl, xalsa, xalda ) 369 644 370 c ********************************************************************** 645 646 implicit none 647 real*8 iaa_f, y 648 649 iaa_fi=iaa_f(1.0/y)/y**2 650 return 651 end 652 653 654 c ********************************************************************** 655 double precision function iaa_f(nuaux) 656 c calculates 1-exp(-k(nu)u) for all series paths or combinations thereof 657 c ********************************************************************** 658 659 implicit none 371 372 implicit none 373 374 include 'nlte_paramdef.h' 375 376 c arguments 377 real*8 y ! I. path's absorber amount * strength 378 real*8 pl ! I. path's partial pressure of CO2 379 real*8 xalsa ! I. Self lorentz linewidth for 1 isot & 1 box 380 real*8 xalda ! I. Doppler linewidth " " 381 382 c local variables 383 integer i 384 real*8 x,wl,wd,wvoigt 385 real*8 cn(0:7),dn(0:7) 386 real*8 factor, denom 387 real*8 pi, pi2, sqrtpi 388 389 c data blocks 390 data cn/9.99998291698d-1,-3.53508187098d-1,9.60267807976d-2, 391 @ -2.04969011013d-2,3.43927368627d-3,-4.27593051557d-4, 392 @ 3.42209457833d-5,-1.28380804108d-6/ 393 data dn/1.99999898289,5.774919878d-1,-5.05367549898d-1, 394 @ 8.21896973657d-1,-2.5222672453,6.1007027481, 395 @ -8.51001627836,4.6535116765/ 396 397 c *********** 398 399 pi = 3.141592 400 pi2= 6.28318531 401 sqrtpi = 1.77245385 402 403 x=y / ( pi2 * xalsa*pl ) 404 405 406 c Lorentz 407 wl=y/sqrt(1.0d0+pi*x/2.0d0) 408 409 c Doppler 410 x = y / (xalda*sqrtpi) 411 if (x .lt. 5.0d0) then 412 wd = cn(0) 413 factor = 1.d0 414 do i=1,7 415 factor = factor * x 416 wd = wd + cn(i) * factor 417 end do 418 wd = xalda * x * sqrtpi * wd 419 else 420 wd = dn(0) 421 factor = 1.d0 / log(x) 422 denom = 1.d0 423 do i=1,7 424 denom = denom * factor 425 wd = wd + dn(i) * denom 426 end do 427 wd = xalda * sqrt(log(x)) * wd 428 end if 429 430 c Voigt 431 wvoigt = wl*wl + wd*wd - (wd*wl/y)*(wd*wl/y) 432 433 if ( wvoigt .lt. 0.0d0 ) then 434 write (*,*) ' Subroutine WE/ Error in Voift EQS calculation ' 435 write (*,*) ' WL, WD, X, Y = ', wl, wd, x, y 436 stop ' ERROR : Imaginary EQW. Revise spectral data. ' 437 endif 438 439 we_clean = sqrt( wvoigt ) 440 441 442 return 443 end 444 445 446 c *********************************************************************** 447 448 subroutine mztf_correccion (coninf, con, ib ) 449 450 c *********************************************************************** 451 452 implicit none 453 660 454 include 'nlte_paramdef.h' 661 455 include 'nlte_commons.h' 662 663 double precision tra,xa,ya,za,yy,nuaux 664 double precision voigtf 665 tra=1.0d0 666 667 yy=1.0d0/alda(kr) 668 xa=nuaux*yy 669 ya= ( alsa(kr)*pp + alna(kr)*(pt-pp) ) * yy 670 za=ka(kr)*yy 671 672 if(icls.eq.5) then !para mztf 673 ! write (*,*) 'icls=',icls 674 tra=za*ua(kr)*voigtf(sngl(xa),sngl(ya)) 456 457 c arguments 458 integer ib 459 real*8 con(nzy), coninf 460 461 ! local variables 462 integer i, isot 463 real*8 tvt0(nzy), tvtbs(nzy), zld(nl),zyd(nzy) 464 real*8 xqv, xes, xlower, xfactor 465 466 c ********* 467 468 isot = 1 469 nu11 = dble( nu(1,1) ) 470 471 do i=1,nzy 472 zyd(i) = dble(zy(i)) 473 enddo 474 do i=1,nl 475 zld(i) = dble( zl(i) ) 476 end do 477 478 ! tvtbs 479 call interhuntdp (tvtbs,zyd,nzy, v626t1,zld,nl, 1 ) 480 481 ! tvt0 482 if (ib.eq.2 .or. ib.eq.3 .or. ib.eq.4) then 483 call interhuntdp (tvt0,zyd,nzy, v626t1,zld,nl, 1 ) 675 484 else 676 tra=za*sl_ua*voigtf(sngl(xa),sngl(ya)) 677 end if 678 679 if (tra.gt.50.0) then 680 tra=1.0 !2.0e-22 overflow cut-off. 681 else if (tra.gt.1.0e-4) then 682 tra=1.0-exp(-tra) 683 end if 684 685 iaa_f=tra 686 return 687 end 688 689 c ********************************************************************** 690 double precision function voigtf(x1,y) 691 c computes voigt function for any value of x1 and any +ve value of y. 692 c where possible uses modified lorentz and modified doppler approximatio 693 c otherwise uses a rearranged rybicki routine. 694 c c(n) = exp(-(n/h)**2)/(pi*sqrt(pi)), with h = 2.5 . 695 c accurate to better than 1 in 10000. 696 c ********************************************************************** 697 698 implicit none 699 700 real x1, y 701 real x, xx, xxyy, xh,xhxh, yh,yhyh, f1,f2, p, q, xn,xnxn, voig 702 703 real*8 b,g0,g1,g2,g3,g4,d1,d2,d3,d4,c 704 integer*4 n 705 706 dimension c(10) 707 complex xp,xpp,z 708 709 data c(1)/0.15303405/ 710 data c(2)/0.94694928e-1/ 711 data c(3)/0.42549174e-1/ 712 data c(4)/0.13882935e-1/ 713 data c(5)/0.32892528e-2/ 714 data c(6)/0.56589906e-3/ 715 data c(7)/0.70697890e-4/ 716 data c(8)/0.64135678e-5/ 717 data c(9)/0.42249221e-6/ 718 data c(10)/0.20209868e-7/ 719 720 x=abs(x1) 721 if (x.gt.7.2) goto 1 722 if ((y+x*0.3).gt.5.4) goto 1 723 if (y.gt.0.01) goto 3 724 if (x.lt.2.1) goto 2 725 goto 3 726 c here uses modified lorentz approx. 727 1 xx=x*x 728 xxyy=xx+y*y 729 b=xx/xxyy 730 voigtf=y*(1.+(2.*b-0.5+(0.75-(9.-12.*b)*b)/xxyy)/ 731 * xxyy)/(xxyy*3.141592654) 732 return 733 c here uses modified doppler approx. 734 2 xx=x*x 735 voigtf=0.56418958*exp(-xx)*(1.-y*(1.-0.5*y)*(1.1289-xx*(1.1623+ 736 * xx*(0.080812+xx*(0.13854-xx*(0.033605-0.0073972*xx)))))) 737 return 738 c here uses a rearranged rybicki routine. 739 3 xh=2.5*x 740 xhxh=xh*xh 741 yh=2.5*y 742 yhyh=yh*yh 743 f1=xhxh+yhyh 744 f2=f1-0.5*yhyh 745 if (y.lt.0.1) goto 20 746 p=-y*7.8539816 !7.8539816=2.5*pi 747 q=x*7.8539816 748 xpp=cmplx(p,q) 749 z=cexp(xpp) 750 d1=xh*aimag(z) 751 d2=-d1 752 d3=yh*(1.-real(z)) 753 d4=-d3+2.*yh 754 voig=0.17958712*(d1+d3)/f1 755 goto 30 756 20 p=x*7.8539816 757 q=y*7.8539816 758 xp=cmplx(p,q) 759 z=ccos(xp) 760 d1=xh*aimag(z) 761 d2=-d1 762 d3=yh*(1.-real(z)) 763 d4=-d3+2.*yh 764 voig=0.56418958*exp(y*y-x*x)*cos(2.*x*y)+0.17958712*(d1+d3)/f1 765 30 xn=0. 766 do 55 n=1,10,2 767 xn=xn+1. 768 xnxn=xn*xn 769 g1=xh-xn 770 g2=g1*(xh+xn) 771 g3=0.5*g2*g2 772 voig=voig+c(n)*(d2*(g2+yhyh)+d4*(f1+xnxn))/ 773 & (g3+yhyh*(f2+xnxn)) 774 xn=xn+1. 775 xnxn=xn*xn 776 g1=xh-xn 777 g2=g1*(xh+xn) 778 g3=0.5*g2*g2 779 voig=voig+c(n+1)*(d1*(g2+yhyh)+d3*(f1+xnxn))/ 780 @ (g3+yhyh*(f2+xnxn)) 781 55 continue 782 voigtf=voig 783 return 784 end 785 786 787 788 c ********************************************************************** 789 c elimin_mz1d.F (includes smooth_cf) 790 c ************************************************************************ 791 subroutine elimin_mz1d (c,vc, ilayer,nanaux,itblout, nwaux) 792 793 c Eliminate anomalous negative numbers in c(nl,nl) according to "nanaux": 794 795 c nanaux = 0 -> no eliminate 796 c @ -> eliminate all numbers with absol.value<abs(max(c(n,r)))/300. 797 c 2 -> eliminate all anomalous negative numbers in c(n,r). 798 c 3 -> eliminate all anomalous negative numbers far from the main 799 c diagonal. 800 c 8 -> eliminate all non-zero numbers outside the main diagonal, 801 c and the contibution of lower boundary. 802 c 9 -> eliminate all non-zero numbers outside the main diagonal. 803 c 4 -> hace un smoothing cuando la distancia de separacion entre 804 c el valor maximo y el minimo de cf > 50 capas. 805 c 5 -> elimina valores menores que 1.0d-19 806 c 6 -> incluye los dos casos 4 y 5 807 c 7 -> llama a lisa: smooth con width=nw & elimina mejorado 808 c 78-> incluye los dos casos 7 y 8 809 c 79-> incluye los dos casos 7 y 9 810 811 c itblout (itableout in calling program) is the option for writing 812 c out or not the purged c(n,r) matrix: 813 c itblout = 0 -> no write 814 c = 1 -> write out in curtis***.out according to ilayer 815 816 c ilayer is the index for the layer selected to write out the matrix: 817 c ilayer = 0 => matrix elements written out cover all the altitudes 818 c with 5 layers steps 819 c > 0 => " " " " are c(ilayer,*) 820 c NOTA: 821 c EXISTE LA POSIBILIDAD DE SACAR TODAS LAS CAPAS (TODA LA MATRIZ) 822 c UTILIZANDO itableout=30 EN MZTUD 823 824 c jul 2011 malv+fgg adapted to LMD-MGCM 825 c Sep-04 FGG+MALV Correct include and call parameters 826 c cristina 25-sept-1996 y 27-ene-1997 827 c JAN 98 MALV Version for mz1d 828 c ************************************************************************ 485 do i=1,nzy 486 tvt0(i) = dble( ty(i) ) 487 end do 488 end if 489 490 c factor 491 do i=1,nzy 492 493 xlower = exp( ee*dble(elow(isot,ib)) * 494 @ ( 1.d0/dble(ty(i))-1.d0/tvt0(i) ) ) 495 xes = 1.0d0 496 xqv = ( 1.d0-exp( -ee*nu11/tvtbs(i) ) ) / 497 @ (1.d0-exp( -ee*nu11/dble(ty(i)) )) 498 xfactor = xlower * xqv**2.d0 * xes 499 500 con(i) = con(i) * xfactor 501 if (i.eq.nzy) coninf = coninf * xfactor 502 503 end do 504 505 506 return 507 end 508 509 510 c *********************************************************************** 511 512 subroutine mzescape_normaliz ( taustar, istyle ) 513 514 c *********************************************************************** 515 516 implicit none 517 include 'nlte_paramdef.h' 518 519 c arguments 520 real*8 taustar(nl) ! o 521 integer istyle ! i 522 523 c local variables and constants 524 integer i, imaximum 525 real*8 maximum 526 527 c *************** 528 529 taustar(nl) = taustar(nl-1) 530 531 if ( istyle .eq. 1 ) then 532 imaximum = nl 533 maximum = taustar(nl) 534 do i=1,nl-1 535 if (taustar(i).gt.maximum) taustar(i) = taustar(nl) 536 enddo 537 elseif ( istyle .eq. 2 ) then 538 imaximum = nl 539 maximum = taustar(nl) 540 do i=nl-1,1,-1 541 if (taustar(i).gt.maximum) then 542 maximum = taustar(i) 543 imaximum = i 544 endif 545 enddo 546 do i=imaximum,nl 547 if (taustar(i).lt.maximum) taustar(i) = maximum 548 enddo 549 endif 550 551 do i=1,nl 552 taustar(i) = taustar(i) / maximum 553 enddo 554 555 556 c end 557 return 558 end 559 560 c *********************************************************************** 561 562 subroutine mzescape_normaliz_02 ( taustar, nn, istyle ) 563 564 c *********************************************************************** 565 566 implicit none 567 568 c arguments 569 real*8 taustar(nn) ! i,o 570 integer istyle ! i 571 integer nn ! i 572 573 c local variables and constants 574 integer i, imaximum 575 real*8 maximum 576 577 c *************** 578 579 taustar(nn) = taustar(nn-1) 580 581 if ( istyle .eq. 1 ) then 582 imaximum = nn 583 maximum = taustar(nn) 584 do i=1,nn-1 585 if (taustar(i).gt.maximum) taustar(i) = taustar(nn) 586 enddo 587 elseif ( istyle .eq. 2 ) then 588 imaximum = nn 589 maximum = taustar(nn) 590 do i=nn-1,1,-1 591 if (taustar(i).gt.maximum) then 592 maximum = taustar(i) 593 imaximum = i 594 endif 595 enddo 596 do i=imaximum,nn 597 if (taustar(i).lt.maximum) taustar(i) = maximum 598 enddo 599 endif 600 601 do i=1,nn 602 taustar(i) = taustar(i) / maximum 603 enddo 604 605 606 c end 607 return 608 end 609 610 611 c *** interdp_ESCTVCISO_dlvr11.f *** 612 613 c*********************************************************************** 614 615 subroutine interdp_ESCTVCISO 616 617 c*********************************************************************** 829 618 830 619 implicit none … … 833 622 include 'nlte_commons.h' 834 623 835 integer nanaux,j,i,itblout,kk,k,ir,in 836 integer ilayer,jmin, jmax,np,nwaux,ntimes,ntimes2 837 !* real*8 c(nl,nl), vc(nl), amax, cmax, cmin, cs(nl,nl), mini 838 real*8 c(nl,nl), vc(nl), amax, cmax, cmin, mini 839 real*8 aux(nl), auxs(nl) 840 character layercode*3 841 842 ntimes=0 843 ntimes2=0 844 ! type *,'from elimin_mz4: nan, nw',nan,nw 845 846 if (nanaux .eq. 0) goto 200 847 848 if(nanaux.eq.1)then 849 do i=1,nl 850 amax=1.0d-36 851 do j=1,nl 852 if(abs(c(i,j)).gt.amax)amax=abs(c(i,j)) 853 end do 854 do j=1,nl 855 if(abs(c(i,j)).lt.amax/300.0d0)c(i,j)=0.0d0 856 end do 857 enddo 858 elseif(nanaux.eq.2)then 859 do i=1,nl 860 do j=1,nl 861 if( ( j.le.(i-2) .or. j.gt.(i+2) ).and. 862 @ ( c(i,j).lt.0.0d0 ) ) c(i,j)=0.0d0 863 end do 864 enddo 865 elseif(nanaux.eq.3)then 866 do i=1,nl 867 do j=1,nl 868 if (abs(i-j).ge.10) c(i,j)=0.0d0 869 end do 870 enddo 871 elseif(nanaux.eq.8)then 872 do i=1,nl 873 do j=1,i-1 874 c(i,j)=0.0d0 875 enddo 876 do j=i+1,nl 877 c(i,j)=0.0d0 878 enddo 879 vc(i)= 0.d0 880 enddo 881 elseif(nanaux.eq.9)then 882 do i=1,nl 883 do j=1,i-1 884 c(i,j)=0.0d0 885 enddo 886 do j=i+1,nl 887 c(i,j)=0.0d0 888 enddo 889 enddo 890 ! elseif(nan.eq.7.or.nan.eq.78.or.nan.eq.79)then 891 ! call lisa(c, vc, nl, nw) 892 end if 893 if(nanaux.eq.78)then 894 do i=1,nl 895 do j=1,i-1 896 c(i,j)=0.0d0 897 enddo 898 do j=i+1,nl 899 c(i,j)=0.0d0 900 enddo 901 vc(i)= 0.d0 902 enddo 903 endif 904 if(nanaux.eq.79)then 905 do i=1,nl 906 do j=1,i-1 907 c(i,j)=0.0d0 908 enddo 909 do j=i+1,nl 910 c(i,j)=0.0d0 911 enddo 912 enddo 913 endif 914 915 if(nanaux.eq.5.or.nanaux.eq.6)then 916 do i=1,nl 917 mini = 1.0d-19 918 do j=1,nl 919 if(abs(c(i,j)).le.mini.and.c(i,j).ne.0.d0) then 920 ntimes2=ntimes2+1 921 end if 922 if ( abs(c(i,j)).le.mini) c(i,j)=0.d0 923 end do 924 enddo 925 end if 926 927 if(nanaux.eq.4.or.nanaux.eq.6)then 928 do i=1,nl 929 do j=1,nl 930 aux(j)=c(i,j) 931 auxs(j)=c(i,j) 932 end do 933 !call maxdp_2(aux,nl,cmax,jmax) 934 cmax=maxval(aux) 935 jmax=maxloc(aux,dim=1) 936 if(abs(jmax-i).ge.50) then 937 call smooth_cf(aux,auxs,i,nl,3) 938 !!!call smooth_cf(aux,auxs,i,nl,5) 939 ntimes=ntimes+1 940 end if 941 do j=1,nl 942 c(i,j)=auxs(j) 943 end do 944 end do 945 end if 946 947 ! type *, 'elimin_mz4: c(n,r) procesed for elimination. ' 948 ! type *, ' ' 949 ! if(nan.eq.4.or.nan.eq.6) type *, ' call smoothing:',ntimes 950 ! if(nan.eq.5.or.nan.eq.6) type *, ' call elimina: ',ntimes2 951 ! if(nan.eq.7) type *, ' from elimin: lisa w=',nw 952 ! type *, ' ' 953 954 955 200 continue 956 957 c writting out of c(n,r) in ascii file 958 959 ! if(itblout.eq.1) then 960 961 ! if (ilayer.eq.0) then 962 963 ! open (unit=2, status='new', 964 ! @ file=dircurtis//'curtis_gnu.out', recl=1024) 965 ! write(2,'(a)') 966 ! @ ' curtis matrix: table with 1.e+7 * acf(n,r) ' 967 ! write(2,114) 'n,r', ( i, i=nl,1,-5 ) 968 ! do in=nl,1,-5 969 ! write(2,*) 970 ! write(2,115) in, ( c(in,ir)*1.d7, ir=nl,1,-5 ) 971 ! end do 972 ! close(2) 973 974 975 ! write (*,*) ' ' 976 ! write (*,*) ' curtis.out has been created. ' 977 ! write (*,*) ' ' 978 979 ! else 980 981 ! write (layercode,132) ilayer 982 ! open (2, status='new', 983 ! @ file=dircurtis//'curtis'//layercode//'.out') 984 ! write(2,'(a)') 985 ! @ ' curtis matrix: table with 1.e+7 * acf(n,r) ' 986 ! write(2,116) ' layer x c(',layercode, 987 ! @ ',x) c(x,', layercode,')' 988 ! do in=nl,1,-1 989 ! if (c(ilayer,ilayer).ne.0.d0) then 990 ! write(2,117) in, c(ilayer,in), c(in,ilayer), 991 ! @ c(ilayer,in)/c(ilayer,ilayer), 992 ! @ c(in,ilayer)/c(ilayer,ilayer) 993 ! else 994 ! write(2,118) in, c(ilayer,in), c(in,ilayer) 995 ! end if 996 ! end do 997 ! close(2) 998 ! write (*,*) ' ' 999 ! write (*,*) dircurtis//'curtis'//layercode//'.out', 1000 ! @ ' has been created.' 1001 ! write (*,*) ' ' 1002 1003 ! end if 1004 1005 ! elseif(itblout.eq.0)then 1006 1007 ! continue 1008 1009 ! else 1010 1011 ! write (*,*) ' error from elimin: ', 1012 ! @ ' itblout should be 1 or 0; itblout= ',itblout 1013 ! stop 1014 1015 ! end if 1016 1017 return 1018 1019 112 format(10x,10(i3,9x)) 1020 113 format(1x,i3,2x,9(1pe9.2,2x)) 624 c local variables 625 integer i 626 real*8 lnpnb(nl) 627 628 629 c*********************************************************************** 630 631 c Use pressure in the NLTE grid but in log and in nb 632 do i=1,nl 633 lnpnb(i) = log( dble( pl(i) * 1013.25 * 1.e6) ) 634 enddo 635 636 c Interpolations 637 638 call interhuntdp3veces 639 @ ( taustar21,taustar31,taustar41, lnpnb, nl, 640 @ tstar21tab,tstar31tab,tstar41tab, lnpnbtab, nztabul, 641 @ 1 ) 642 643 call interhuntdp3veces ( vc210,vc310,vc410, lnpnb, nl, 644 @ vc210tab,vc310tab,vc410tab, lnpnbtab, nztabul, 2 ) 645 646 c end 647 return 648 end 649 650 651 c *** hunt_cts.f *** 652 653 cccc 654 SUBROUTINE hunt_cts(xx,n,n_cts,x,jlo) 655 c 656 c La dif con hunt es el uso de un indice superior (n_cts) mas bajito que (n) 657 c 658 c Arguments 659 INTEGER jlo ! O 660 INTEGER n ! I 661 INTEGER n_cts ! I 662 REAL xx(n) ! I 663 REAL x ! I 664 665 c Local variables 666 INTEGER inc,jhi,jm 667 LOGICAL ascnd 668 c 669 cccc 670 c 671 ascnd=xx(n_cts).ge.xx(1) 672 if(jlo.le.0.or.jlo.gt.n_cts)then 673 jlo=0 674 jhi=n_cts+1 675 goto 3 676 endif 677 inc=1 678 if(x.ge.xx(jlo).eqv.ascnd)then 679 1 jhi=jlo+inc 680 ! write (*,*) jlo 681 if(jhi.gt.n_cts)then 682 jhi=n_cts+1 683 ! write (*,*) jhi-1 684 else if(x.ge.xx(jhi).eqv.ascnd)then 685 jlo=jhi 686 inc=inc+inc 687 ! write (*,*) jlo 688 goto 1 689 endif 690 else 691 jhi=jlo 692 2 jlo=jhi-inc 693 ! write (*,*) jlo 694 if(jlo.lt.1)then 695 jlo=0 696 else if(x.lt.xx(jlo).eqv.ascnd)then 697 jhi=jlo 698 inc=inc+inc 699 goto 2 700 endif 701 endif 702 3 if(jhi-jlo.eq.1)then 703 if(x.eq.xx(n_cts))jlo=n_cts-1 704 if(x.eq.xx(1))jlo=1 705 ! write (*,*) jlo 706 return 707 endif 708 jm=(jhi+jlo)/2 709 if(x.ge.xx(jm).eqv.ascnd)then 710 jlo=jm 711 else 712 jhi=jm 713 endif 714 ! write (*,*) jhi-1 715 goto 3 716 c 717 END 718 1021 719 1022 114 format(1x,a3, 11(8x,i3)) 1023 115 format( 1x,i3, 2x, 11(1pe10.3)) 1024 116 format( 1x,a17,a2,a18,a2,a1 ) 1025 117 format( 3x,i3, 4(8x,1pe10.3) ) 1026 118 format( 3x,i3, 2(8x,1pe10.3) ) 1027 120 format( 1x,i3, 1x,i3, 2x, 11(1pe10.3)) 1028 1029 132 format(i3) 1030 1031 ! cambio: los formatos 114, 115 , 117 y 118 1032 ! cambio: al cambia nl de 51 a 140 hay que cambiar el formato i2-->i3 1033 ! y ahora en vez de 11 capas de 5 en 5, hay 28 1034 ! 1035 end 1036 c************************************************************************** 1037 subroutine smooth_cf( c, cs, i, nl, w ) 1038 c hace un smoothing de c(i,*), de la contribucion de todas las capas 1039 c menos de la capa en cuestion, la i. 1040 c opcion w (width): el tamanho de la ventana del smoothing. 1041 c output values: cs 1042 c************************************************************************** 1043 1044 implicit none 720 c *** huntdp.f *** 721 722 cccc 723 SUBROUTINE huntdp(xx,n,x,jlo) 724 c 725 c Arguments 726 INTEGER jlo ! O 727 INTEGER n ! I 728 REAL*8 xx(n) ! I 729 REAL*8 x ! I 730 731 c Local variables 732 INTEGER inc,jhi,jm 733 LOGICAL ascnd 734 c 735 cccc 736 c 737 ascnd=xx(n).ge.xx(1) 738 if(jlo.le.0.or.jlo.gt.n)then 739 jlo=0 740 jhi=n+1 741 goto 3 742 endif 743 inc=1 744 if(x.ge.xx(jlo).eqv.ascnd)then 745 1 jhi=jlo+inc 746 if(jhi.gt.n)then 747 jhi=n+1 748 else if(x.ge.xx(jhi).eqv.ascnd)then 749 jlo=jhi 750 inc=inc+inc 751 goto 1 752 endif 753 else 754 jhi=jlo 755 2 jlo=jhi-inc 756 if(jlo.lt.1)then 757 jlo=0 758 else if(x.lt.xx(jlo).eqv.ascnd)then 759 jhi=jlo 760 inc=inc+inc 761 goto 2 762 endif 763 endif 764 3 if(jhi-jlo.eq.1)then 765 if(x.eq.xx(n))jlo=n-1 766 if(x.eq.xx(1))jlo=1 767 return 768 endif 769 jm=(jhi+jlo)/2 770 if(x.ge.xx(jm).eqv.ascnd)then 771 jlo=jm 772 else 773 jhi=jm 774 endif 775 goto 3 776 c 777 END 778 1045 779 1046 integer j,np,i,nl,w 1047 real*8 c(nl), cs(nl) 1048 1049 if(w.eq.0) then 1050 do j=1,nl 1051 cs(j)=c(j) 1052 end do 1053 1054 elseif(w.eq.3) then 1055 1056 ! write (*,*) 'smoothing w=3' 1057 do j=1,i-4 1058 if(j.eq.1) then 1059 cs(j)=c(j) 1060 else 1061 cs(j)=1/3.d0*(c(j-1)+c(j)+c(j+1)) 1062 end if 1063 end do 1064 do j=i+4,nl-1 1065 if(j.eq.nl) then 1066 cs(j)=c(j) 1067 else 1068 cs(j)=1/3.d0*(c(j-1)+c(j)+c(j+1)) 1069 end if 1070 end do 1071 elseif(w.eq.5) then 1072 1073 ! type *,'smoothing w=5' 1074 do j=3,i-4 1075 if(j.eq.1) then 1076 cs(j)=c(j) 1077 else 1078 cs(j)=1/5.d0*(c(j-2)+c(j-1)+c(j)+c(j+1)+c(j+2)) 1079 end if 1080 end do 1081 do j=i+4,nl-2 1082 if(j.eq.nl) then 1083 cs(j)=c(j) 1084 else 1085 cs(j)=1/5.d0*(c(j-2)+c(j-1)+c(j)+c(j+1)+c(j+2)) 1086 end if 1087 end do 1088 end if 1089 return 1090 end 1091 1092 1093 1094 c***************************************************************************** 1095 c suaviza 1096 c***************************************************************************** 1097 c 1098 subroutine suaviza ( x, n, ismooth, y ) 1099 c 1100 c x - input and return values 1101 c y - auxiliary vector 1102 c ismooth = 0 --> no smoothing is performed 1103 c ismooth = 1 --> weak smoothing (5 points, centred weighted) 1104 c ismooth = 2 --> normal smoothing (3 points, evenly weighted) 1105 c ismooth = 3 --> strong smoothing (5 points, evenly weighted) 1106 1107 1108 c malv august 1991 1109 c***************************************************************************** 1110 1111 implicit none 1112 1113 integer n, imax, imin, i, ismooth 1114 real*8 x(n), y(n) 1115 c***************************************************************************** 1116 1117 imin=1 1118 imax=n 1119 1120 if (ismooth.eq.0) then 1121 1122 return 1123 1124 elseif (ismooth.eq.1) then ! 5 points, with central weighting 1125 1126 do i=imin,imax 1127 if(i.eq.imin)then 1128 y(i)=x(imin) 1129 elseif(i.eq.imax)then 1130 y(i)=x(imax-1)+(x(imax-1)-x(imax-3))/2.d0 1131 elseif(i.gt.(imin+1) .and. i.lt.(imax-1) )then 1132 y(i) = ( x(i+2)/4.d0 + x(i+1)/2.d0 + 2.d0*x(i)/3.d0 + 1133 & x(i-1)/2.d0 + x(i-2)/4.d0 )* 6.d0/13.d0 1134 else 1135 y(i)=(x(i+1)/2.d0+x(i)+x(i-1)/2.d0)/2.d0 1136 end if 1137 end do 1138 1139 elseif (ismooth.eq.2) then ! 3 points, evenly spaced 1140 1141 do i=imin,imax 1142 if(i.eq.imin)then 1143 y(i)=x(imin) 1144 elseif(i.eq.imax)then 1145 y(i)=x(imax-1)+(x(imax-1)-x(imax-3))/2.d0 1146 else 1147 y(i) = ( x(i+1)+x(i)+x(i-1) )/3.d0 1148 end if 1149 end do 1150 1151 elseif (ismooth.eq.3) then ! 5 points, evenly spaced 1152 1153 do i=imin,imax 1154 if(i.eq.imin)then 1155 y(i) = x(imin) 1156 elseif(i.eq.(imin+1) .or. i.eq.(imax-1))then 1157 y(i) = ( x(i+1)+x(i)+x(i-1) )/3.d0 1158 elseif(i.eq.imax)then 1159 y(i) = ( x(imax-1) + x(imax-1) + x(imax-2) ) / 3.d0 1160 else 1161 y(i) = ( x(i+2)+x(i+1)+x(i)+x(i-1)+x(i-2) )/5.d0 1162 end if 1163 end do 1164 1165 else 1166 1167 write (*,*) ' Error in suaviza.f Wrong ismooth value.' 1168 stop 1169 1170 endif 1171 1172 c rehago el cambio, para devolver x(i) 1173 do i=imin,imax 1174 x(i)=y(i) 1175 end do 1176 1177 return 1178 end 1179 1180 1181 1182 1183 c***************************************************************************** 1184 c LUdec.F (includes lubksb_dp and ludcmp_dp subroutines) 1185 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1186 c 1187 c Solution of linear equation without inverting matrix 1188 c using LU decomposition: 1189 c AA * xx = bb AA, bb: known 1190 c xx: to be found 1191 c AA and bb are not modified in this subroutine 1192 c 1193 c MALV , Sep 2007 1194 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1195 1196 subroutine LUdec(xx,aa,bb,m,n) 1197 1198 implicit none 1199 1200 ! Arguments 1201 integer,intent(in) :: m, n 1202 real*8,intent(in) :: aa(m,m), bb(m) 1203 real*8,intent(out) :: xx(m) 1204 1205 1206 ! Local variables 1207 real*8 a(n,n), b(n), x(n), d 1208 integer i, j, indx(n) 1209 1210 1211 ! Subrutinas utilizadas 1212 ! ludcmp_dp, lubksb_dp 1213 1214 !!!!!!!!!!!!!!! Comienza el programa !!!!!!!!!!!!!! 780 c *** hunt.f *** 781 782 cccc 783 SUBROUTINE hunt(xx,n,x,jlo) 784 c 785 c Arguments 786 INTEGER jlo ! O 787 INTEGER n ! I 788 REAL xx(n) ! I 789 REAL x ! I 790 791 c Local variables 792 INTEGER inc,jhi,jm 793 LOGICAL ascnd 794 c 795 cccc 796 c 797 ascnd=xx(n).ge.xx(1) 798 if(jlo.le.0.or.jlo.gt.n)then 799 jlo=0 800 jhi=n+1 801 goto 3 802 endif 803 inc=1 804 if(x.ge.xx(jlo).eqv.ascnd)then 805 1 jhi=jlo+inc 806 ! write (*,*) jlo 807 if(jhi.gt.n)then 808 jhi=n+1 809 ! write (*,*) jhi-1 810 else if(x.ge.xx(jhi).eqv.ascnd)then 811 jlo=jhi 812 inc=inc+inc 813 ! write (*,*) jlo 814 goto 1 815 endif 816 else 817 jhi=jlo 818 2 jlo=jhi-inc 819 ! write (*,*) jlo 820 if(jlo.lt.1)then 821 jlo=0 822 else if(x.lt.xx(jlo).eqv.ascnd)then 823 jhi=jlo 824 inc=inc+inc 825 goto 2 826 endif 827 endif 828 3 if(jhi-jlo.eq.1)then 829 if(x.eq.xx(n))jlo=n-1 830 if(x.eq.xx(1))jlo=1 831 ! write (*,*) jlo 832 return 833 endif 834 jm=(jhi+jlo)/2 835 if(x.ge.xx(jm).eqv.ascnd)then 836 jlo=jm 837 else 838 jhi=jm 839 endif 840 ! write (*,*) jhi-1 841 goto 3 842 c 843 END 844 1215 845 1216 do i=1,n 1217 b(i) = bb(i+1) 1218 do j=1,n 1219 a(i,j) = aa(i+1,j+1) 1220 enddo 1221 enddo 1222 1223 ! Descomposicion de auxm1 1224 call ludcmp_dp ( a, n, n, indx, d) 1225 1226 ! Sustituciones foward y backwards para hallar la solucion 1227 do i=1,n 1228 x(i) = b(i) 1229 enddo 1230 call lubksb_dp( a, n, n, indx, x ) 1231 1232 do i=1,n 1233 xx(i+1) = x(i) 1234 enddo 1235 1236 return 1237 end 1238 1239 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1240 1241 subroutine ludcmp_dp(a,n,np,indx,d) 1242 1243 c jul 2011 malv+fgg 1244 1245 implicit none 1246 1247 integer,intent(in) :: n, np 1248 real*8,intent(inout) :: a(np,np) 1249 real*8,intent(out) :: d 1250 integer,intent(out) :: indx(n) 1251 1252 integer i, j, k, imax 1253 real*8,parameter :: tiny=1.0d-20 1254 real*8 vv(n), aamax, sum, dum 1255 1256 1257 d=1.0d0 1258 do 12 i=1,n 1259 aamax=0.0d0 1260 do 11 j=1,n 1261 if (abs(a(i,j)).gt.aamax) aamax=abs(a(i,j)) 1262 11 continue 1263 if (aamax.eq.0.0) then 1264 write(*,*) 'ludcmp_dp: singular matrix!' 1265 stop 1266 endif 1267 vv(i)=1.0d0/aamax 1268 12 continue 1269 do 19 j=1,n 1270 if (j.gt.1) then 1271 do 14 i=1,j-1 1272 sum=a(i,j) 1273 if (i.gt.1)then 1274 do 13 k=1,i-1 1275 sum=sum-a(i,k)*a(k,j) 1276 13 continue 1277 a(i,j)=sum 1278 endif 1279 14 continue 1280 endif 1281 aamax=0.0d0 1282 do 16 i=j,n 1283 sum=a(i,j) 1284 if (j.gt.1)then 1285 do 15 k=1,j-1 1286 sum=sum-a(i,k)*a(k,j) 1287 15 continue 1288 a(i,j)=sum 1289 endif 1290 dum=vv(i)*abs(sum) 1291 if (dum.ge.aamax) then 1292 imax=i 1293 aamax=dum 1294 endif 1295 16 continue 1296 if (j.ne.imax)then 1297 do 17 k=1,n 1298 dum=a(imax,k) 1299 a(imax,k)=a(j,k) 1300 a(j,k)=dum 1301 17 continue 1302 d=-d 1303 vv(imax)=vv(j) 1304 endif 1305 indx(j)=imax 1306 if(j.ne.n)then 1307 if(a(j,j).eq.0.0)a(j,j)=tiny 1308 dum=1.0d0/a(j,j) 1309 do 18 i=j+1,n 1310 a(i,j)=a(i,j)*dum 1311 18 continue 1312 endif 1313 19 continue 1314 if(a(n,n).eq.0.0)a(n,n)=tiny 1315 return 1316 end 1317 1318 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1319 1320 subroutine lubksb_dp(a,n,np,indx,b) 1321 1322 c jul 2011 malv+fgg 1323 1324 implicit none 1325 1326 integer,intent(in) :: n,np 1327 real*8,intent(in) :: a(np,np) 1328 integer,intent(in) :: indx(n) 1329 real*8,intent(out) :: b(n) 1330 1331 real*8 sum 1332 integer ii, ll, i, j 1333 1334 ii=0 1335 do 12 i=1,n 1336 ll=indx(i) 1337 sum=b(ll) 1338 b(ll)=b(i) 1339 if (ii.ne.0)then 1340 do 11 j=ii,i-1 1341 sum=sum-a(i,j)*b(j) 1342 11 continue 1343 else if (sum.ne.0.0) then 1344 ii=i 1345 endif 1346 b(i)=sum 1347 12 continue 1348 do 14 i=n,1,-1 1349 sum=b(i) 1350 if(i.lt.n)then 1351 do 13 j=i+1,n 1352 sum=sum-a(i,j)*b(j) 1353 13 continue 1354 endif 1355 b(i)=sum/a(i,i) 1356 14 continue 1357 return 1358 end 1359 1360 1361 1362 1363 c***************************************************************************** 1364 c intersp 1365 c *********************************************************************** 1366 subroutine intersp(yy,zz,m,y,z,n,opt) 1367 c interpolation soubroutine. input values: y(n) at z(n). 1368 c output values: yy(m) at zz(m). options: 1 -> lineal; 2 -> logarithmic 1369 1370 c jul 2011 malv+fgg 1371 c *********************************************************************** 1372 1373 implicit none 1374 1375 integer n,m,i,j,opt 1376 real zz(m),yy(m),z(n),y(n) 1377 real zmin,zzmin,zmax,zzmax 1378 1379 ! write(*,*) ' interpolating' 1380 ! call minsp(z,n,zmin) 1381 zmin=minval(z) 1382 ! call minsp(zz,m,zzmin) 1383 zzmin=minval(zz) 1384 ! call maxsp(z,n,zmax) 1385 zmax=maxval(z) 1386 ! call maxsp(zz,m,zzmax) 1387 zzmax=maxval(zz) 1388 1389 if(zzmin.lt.zmin)then 1390 write(*,*) 'from interp: new variable out of limits' 1391 write(*,*) zzmin,'must be .ge. ',zmin 1392 stop 1393 ! elseif(zzmax.gt.zmax)then 1394 ! write(*,*)'from interp: new variable out of limits' 1395 ! write(*,*)zzmax, 'must be .le. ',zmax 1396 ! stop 1397 end if 1398 1399 do 1,i=1,m 1400 1401 do 2,j=1,n-1 1402 if(zz(i).ge.z(j).and.zz(i).lt.z(j+1)) goto 3 1403 2 continue 1404 c in this case (zz(m).ge.z(n)) and j leaves the loop with j=n-1+1=n 1405 if(opt.eq.1)then 1406 yy(i)=y(n-1)+(y(n)-y(n-1))*(zz(i)-z(n-1))/(z(n)-z(n-1)) 1407 elseif(opt.eq.2)then 1408 if(y(n).eq.0.0.or.y(n-1).eq.0.0)then 1409 yy(i)=0.0 1410 else 1411 yy(i)=exp(log(y(n-1))+log(y(n)/y(n-1))* 1412 @ (zz(i)-z(n-1))/(z(n)-z(n-1))) 1413 end if 1414 else 1415 write(*,*)'from interp error: opt must be 1 or 2, opt= ',opt 1416 end if 1417 goto 1 1418 3 continue 1419 if(opt.eq.1)then 1420 yy(i)=y(j)+(y(j+1)-y(j))*(zz(i)-z(j))/(z(j+1)-z(j)) 1421 elseif(opt.eq.2)then 1422 if(y(j+1).eq.0.0.or.y(j).eq.0.0)then 1423 yy(i)=0.0 1424 else 1425 yy(i)=exp(log(y(j))+log(y(j+1)/y(j))* 1426 @ (zz(i)-z(j))/(z(j+1)-z(j))) 1427 end if 1428 else 1429 write(*,*)'from interp error: opt must be 1 or 2, opt= ',opt 1430 end if 1431 1 continue 1432 1433 return 1434 end 1435 1436 1437 1438 c***************************************************************************** 1439 c interdp 1440 c *********************************************************************** 1441 subroutine interdp(yy,zz,m,y,z,n,opt) 1442 c interpolation soubroutine. input values: y(n) at z(n). 1443 c output values: yy(m) at zz(m). options: 1 -> lineal; 2 -> logarithmic 1444 c jul 2011: malv+fgg Adapted to LMD-MGCM 1445 c *********************************************************************** 1446 implicit none 1447 integer n,m,i,j,opt 1448 real*8 zz(m),yy(m),z(n),y(n), zmin,zzmin,zmax,zzmax 1449 1450 ! write (*,*) ' d interpolating ' 1451 ! call mindp (z,n,zmin) 1452 zmin=minval(z) 1453 ! call mindp (zz,m,zzmin) 1454 zzmin=minval(zz) 1455 ! call maxdp (z,n,zmax) 1456 zmax=maxval(z) 1457 ! call maxdp (zz,m,zzmax) 1458 zzmax=maxval(zz) 846 c *** interdp_limits.f *** 847 848 c *********************************************************************** 849 850 subroutine interdp_limits ( yy, zz, m, i1,i2, 851 @ y, z, n, j1,j2, opt) 852 853 c Interpolation soubroutine. 854 c Returns values between indexes i1 & i2, donde 1 =< i1 =< i2 =< m 855 c Solo usan los indices de los inputs entre j1,j2, 1 =< j1 =< j2 =< n 856 c Input values: y(n) , z(n) (solo se usarann los valores entre j1,j2) 857 c zz(m) (solo se necesita entre i1,i2) 858 c Output values: yy(m) (solo se calculan entre i1,i2) 859 c Options: opt=1 -> lineal ,, opt=2 -> logarithmic 860 c Difference with interdp: 861 c here interpolation proceeds between indexes i1,i2 only 862 c if i1=1 & i2=m, both subroutines are exactly the same 863 c thus previous calls to interdp or interdp2 could be easily replaced 864 865 c JAN 98 MALV Version for mz1d 866 c *********************************************************************** 867 868 implicit none 869 870 ! Arguments 871 integer n,m ! I. Dimensions 872 integer i1, i2, j1, j2, opt ! I 873 real*8 zz(m) ! I 874 real*8 yy(m) ! O 875 real*8 z(n),y(n) ! I 876 877 ! Local variables 878 integer i,j 879 real*8 zmin,zzmin,zmax,zzmax 880 881 c ******************************* 882 883 ! write (*,*) ' d interpolating ' 884 ! call mindp_limits (z,n,zmin, j1,j2) 885 ! call mindp_limits (zz,m,zzmin, i1,i2) 886 ! call maxdp_limits (z,n,zmax, j1,j2) 887 ! call maxdp_limits (zz,m,zzmax, i1,i2) 888 zmin=minval(z(j1:j2)) 889 zzmin=minval(zz(i1:i2)) 890 zmax=maxval(z(j1:j2)) 891 zzmax=maxval(zz(i1:i2)) 1459 892 1460 893 if(zzmin.lt.zmin)then … … 1462 895 write (*,*) zzmin,'must be .ge. ',zmin 1463 896 stop 1464 ! elseif(zzmax.gt.zmax)then 1465 ! write (*,*) 'from interp: new variable out of limits' 1466 ! write (*,*) zzmax, 'must be .le. ',zmax 1467 ! stop 1468 end if 1469 1470 do 1,i=1,m 1471 1472 do 2,j=1,n-1 1473 if(zz(i).ge.z(j).and.zz(i).lt.z(j+1)) goto 3 1474 2 continue 1475 c in this case (zz(m).eq.z(n)) and j leaves the loop with j=n-1+1=n 1476 if(opt.eq.1)then 1477 yy(i)=y(n-1)+(y(n)-y(n-1))*(zz(i)-z(n-1))/(z(n)-z(n-1)) 1478 elseif(opt.eq.2)then 1479 if(y(n).eq.0.0d0.or.y(n-1).eq.0.0d0)then 1480 yy(i)=0.0d0 1481 else 1482 yy(i)=dexp(dlog(y(n-1))+dlog(y(n)/y(n-1))* 1483 @ (zz(i)-z(n-1))/(z(n)-z(n-1))) 1484 end if 1485 else 1486 write (*,*) 1487 @ ' from d interp error: opt must be 1 or 2, opt= ',opt 1488 end if 1489 goto 1 1490 3 continue 1491 if(opt.eq.1)then 1492 yy(i)=y(j)+(y(j+1)-y(j))*(zz(i)-z(j))/(z(j+1)-z(j)) 1493 ! write (*,*) ' ' 1494 ! write (*,*) ' z(j),z(j+1) =', z(j),z(j+1) 1495 ! write (*,*) ' t(j),t(j+1) =', y(j),y(j+1) 1496 ! write (*,*) ' zz, tt = ', zz(i), yy(i) 1497 elseif(opt.eq.2)then 1498 if(y(j+1).eq.0.0d0.or.y(j).eq.0.0d0)then 1499 yy(i)=0.0d0 1500 else 1501 yy(i)=dexp(dlog(y(j))+dlog(y(j+1)/y(j))* 1502 @ (zz(i)-z(j))/(z(j+1)-z(j))) 1503 end if 1504 else 1505 write (*,*) ' from interp error: opt must be 1 or 2, opt= ', 1506 @ opt 1507 end if 1508 1 continue 1509 return 1510 end 1511 1512 1513 c***************************************************************************** 1514 c interdp_limits.F 1515 c *********************************************************************** 1516 1517 subroutine interdp_limits ( yy,zz,m, i1,i2, y,z,n, j1,j2, opt) 1518 1519 c Interpolation soubroutine. 1520 c Returns values between indexes i1 & i2, donde 1 =< i1 =< i2 =< m 1521 c Solo usan los indices de los inputs entre j1,j2, 1 =< j1 =< j2 =< n 1522 c Input values: y(n) , z(n) (solo se usan los valores entre j1,j2) 1523 c zz(m) (solo se necesita entre i1,i2) 1524 c Output values: yy(m) (solo se calculan entre i1,i2) 1525 c Options: opt=1 -> lineal ,, opt=2 -> logarithmic 1526 c Difference with interdp: 1527 c here interpolation proceeds between indexes i1,i2 only 1528 c if i1=1 & i2=m, both subroutines are exactly the same 1529 c thus previous calls to interdp or interdp2 could be easily replaced 1530 1531 c JAN 98 MALV Version for mz1d 1532 c jul 2011 malv+fgg Adapted to LMD-MGCM 1533 c *********************************************************************** 1534 1535 implicit none 1536 1537 ! Arguments 1538 integer n,m ! I. Dimensions 1539 integer i1, i2, j1, j2, opt ! I 1540 real*8 zz(m),yy(m) ! O 1541 real*8 z(n),y(n) ! I 1542 1543 ! Local variables 1544 integer i,j 1545 real*8 zmin,zzmin,zmax,zzmax 1546 1547 c ******************************* 1548 1549 ! type *, ' d interpolating ' 1550 ! call mindp_limits (z,n,zmin, j1,j2) 1551 zmin=minval(z(j1:j2)) 1552 ! call mindp_limits (zz,m,zzmin, i1,i2) 1553 zzmin=minval(zz(i1:i2)) 1554 ! call maxdp_limits (z,n,zmax, j1,j2) 1555 zmax=maxval(z(j1:j2)) 1556 ! call maxdp_limits (zz,m,zzmax, i1,i2) 1557 zzmax=maxval(zz(i1:i2)) 1558 1559 if(zzmin.lt.zmin)then 1560 write (*,*) 'from d interp: new variable out of limits' 1561 write (*,*) zzmin,'must be .ge. ',zmin 1562 stop 1563 ! elseif(zzmax.gt.zmax)then 1564 ! type *,'from interp: new variable out of limits' 1565 ! type *,zzmax, 'must be .le. ',zmax 1566 ! stop 897 ! elseif(zzmax.gt.zmax)then 898 ! type *,'from interp: new variable out of limits' 899 ! type *,zzmax, 'must be .le. ',zmax 900 ! stop 1567 901 end if 1568 902 … … 1572 906 if(zz(i).ge.z(j).and.zz(i).lt.z(j+1)) goto 3 1573 907 2 continue 1574 c 908 c in this case (zz(i2).eq.z(j2)) and j leaves the loop with j=j2-1+1=j2 1575 909 if(opt.eq.1)then 1576 yy(i)=y(j2-1)+(y(j2)-y(j2-1))* 1577 $ (z z(i)-z(j2-1))/(z(j2)-z(j2-1))910 yy(i)=y(j2-1)+(y(j2)-y(j2-1))*(zz(i)-z(j2-1))/ 911 $ (z(j2)-z(j2-1)) 1578 912 elseif(opt.eq.2)then 1579 913 if(y(j2).eq.0.0d0.or.y(j2-1).eq.0.0d0)then … … 1590 924 if(opt.eq.1)then 1591 925 yy(i)=y(j)+(y(j+1)-y(j))*(zz(i)-z(j))/(z(j+1)-z(j)) 1592 ! 1593 ! 1594 ! 1595 ! 926 ! type *, ' ' 927 ! type *, ' z(j),z(j+1) =', z(j),z(j+1) 928 ! type *, ' t(j),t(j+1) =', y(j),y(j+1) 929 ! type *, ' zz, tt = ', zz(i), yy(i) 1596 930 elseif(opt.eq.2)then 1597 931 if(y(j+1).eq.0.0d0.or.y(j).eq.0.0d0)then … … 1610 944 1611 945 1612 1613 c***************************************************************************** 1614 c Subroutines previously included in tcrco2_subrut.F 946 c *** interhunt2veces.f *** 947 948 c *********************************************************************** 949 950 subroutine interhunt2veces ( y1,y2, zz,m, 951 @ x1,x2, z,n, opt) 952 953 c interpolation soubroutine basada en Numerical Recipes HUNT.FOR 954 c input values: y(n) at z(n) 955 c output values: yy(m) at zz(m) 956 c options: 1 -> lineal 957 c 2 -> logarithmic 958 c *********************************************************************** 959 960 implicit none 961 962 ! Arguments 963 integer n,m,opt ! I 964 real zz(m),z(n) ! I 965 real y1(m),y2(m) ! O 966 real x1(n),x2(n) ! I 967 968 969 ! Local variables 970 integer i, j 971 real factor 972 real zaux 973 974 !!!! 975 976 j = 1 ! initial first guess (=n/2 is anothr pssblty) 977 978 do 1,i=1,m ! 979 980 ! Busca indice j donde ocurre q zz(i) esta entre [z(j),z(j+1)] 981 zaux = zz(i) 982 if (abs(zaux-z(1)).le.0.01) then 983 zaux=z(1) 984 elseif (abs(zaux-z(n)).le.0.01) then 985 zaux=z(n) 986 endif 987 call hunt ( z,n, zaux, j ) 988 if ( j.eq.0 .or. j.eq.n ) then 989 write (*,*) ' HUNT/ Limits input grid:', z(1),z(n) 990 write (*,*) ' HUNT/ location in new grid:', zz(i) 991 stop ' interhunt2/ Interpolat error. zz out of limits.' 992 endif 993 994 ! Perform interpolation 995 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 996 if (opt.eq.1) then 997 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 998 y2(i) = x2(j) + (x2(j+1)-x2(j)) * factor 999 else 1000 y1(i) = exp( log(x1(j)) + log(x1(j+1)/x1(j)) * factor ) 1001 y2(i) = exp( log(x2(j)) + log(x2(j+1)/x2(j)) * factor ) 1002 end if 1003 1004 1 continue 1005 1006 return 1007 end 1008 1009 1010 c *** interhunt5veces.f *** 1011 1012 c *********************************************************************** 1013 1014 subroutine interhunt5veces ( y1,y2,y3,y4,y5, zz,m, 1015 @ x1,x2,x3,x4,x5, z,n, opt) 1016 1017 c interpolation soubroutine basada en Numerical Recipes HUNT.FOR 1018 c input values: y(n) at z(n) 1019 c output values: yy(m) at zz(m) 1020 c options: 1 -> lineal 1021 c 2 -> logarithmic 1022 c *********************************************************************** 1023 1024 implicit none 1025 ! Arguments 1026 integer n,m,opt ! I 1027 real zz(m),z(n) ! I 1028 real y1(m),y2(m),y3(m),y4(m),y5(m) ! O 1029 real x1(n),x2(n),x3(n),x4(n),x5(n) ! I 1030 1031 1032 ! Local variables 1033 integer i, j 1034 real factor 1035 real zaux 1036 1037 !!!! 1038 1039 j = 1 ! initial first guess (=n/2 is anothr pssblty) 1040 1041 do 1,i=1,m ! 1042 1043 ! Busca indice j donde ocurre q zz(i) esta entre [z(j),z(j+1)] 1044 zaux = zz(i) 1045 if (abs(zaux-z(1)).le.0.01) then 1046 zaux=z(1) 1047 elseif (abs(zaux-z(n)).le.0.01) then 1048 zaux=z(n) 1049 endif 1050 call hunt ( z,n, zaux, j ) 1051 if ( j.eq.0 .or. j.eq.n ) then 1052 write (*,*) ' HUNT/ Limits input grid:', z(1),z(n) 1053 write (*,*) ' HUNT/ location in new grid:', zz(i) 1054 stop ' interhunt5/ Interpolat error. zz out of limits.' 1055 endif 1056 1057 ! Perform interpolation 1058 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1059 if (opt.eq.1) then 1060 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 1061 y2(i) = x2(j) + (x2(j+1)-x2(j)) * factor 1062 y3(i) = x3(j) + (x3(j+1)-x3(j)) * factor 1063 y4(i) = x4(j) + (x4(j+1)-x4(j)) * factor 1064 y5(i) = x5(j) + (x5(j+1)-x5(j)) * factor 1065 else 1066 y1(i) = exp( log(x1(j)) + log(x1(j+1)/x1(j)) * factor ) 1067 y2(i) = exp( log(x2(j)) + log(x2(j+1)/x2(j)) * factor ) 1068 y3(i) = exp( log(x3(j)) + log(x3(j+1)/x3(j)) * factor ) 1069 y4(i) = exp( log(x4(j)) + log(x4(j+1)/x4(j)) * factor ) 1070 y5(i) = exp( log(x5(j)) + log(x5(j+1)/x5(j)) * factor ) 1071 end if 1072 1073 1 continue 1074 1075 return 1076 end 1077 1078 1079 1080 c *** interhuntdp3veces.f *** 1081 1082 c *********************************************************************** 1083 1084 subroutine interhuntdp3veces ( y1,y2,y3, zz,m, 1085 @ x1,x2,x3, z,n, opt) 1086 1087 c interpolation soubroutine basada en Numerical Recipes HUNT.FOR 1088 c input values: x(n) at z(n) 1089 c output values: y(m) at zz(m) 1090 c options: opt = 1 -> lineal 1091 c opt=/=1 -> logarithmic 1092 c *********************************************************************** 1093 ! Arguments 1094 integer n,m,opt ! I 1095 real*8 zz(m),z(n) ! I 1096 real*8 y1(m),y2(m),y3(m) ! O 1097 real*8 x1(n),x2(n),x3(n) ! I 1098 1099 1100 ! Local variables 1101 integer i, j 1102 real*8 factor 1103 real*8 zaux 1104 1105 !!!! 1106 1107 j = 1 ! initial first guess (=n/2 is anothr pssblty) 1108 1109 do 1,i=1,m ! 1110 1111 ! Busca indice j donde ocurre q zz(i) esta entre [z(j),z(j+1)] 1112 zaux = zz(i) 1113 if (abs(zaux-z(1)).le.0.01d0) then 1114 zaux=z(1) 1115 elseif (abs(zaux-z(n)).le.0.01d0) then 1116 zaux=z(n) 1117 endif 1118 call huntdp ( z,n, zaux, j ) 1119 if ( j.eq.0 .or. j.eq.n ) then 1120 write (*,*) ' HUNT/ Limits input grid:', z(1),z(n) 1121 write (*,*) ' HUNT/ location in new grid:', zz(i) 1122 stop ' INTERHUNTDP3/ Interpolat error. zz out of limits.' 1123 endif 1124 1125 ! Perform interpolation 1126 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1127 if (opt.eq.1) then 1128 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 1129 y2(i) = x2(j) + (x2(j+1)-x2(j)) * factor 1130 y3(i) = x3(j) + (x3(j+1)-x3(j)) * factor 1131 else 1132 y1(i) = dexp( dlog(x1(j)) + dlog(x1(j+1)/x1(j)) * factor ) 1133 y2(i) = dexp( dlog(x2(j)) + dlog(x2(j+1)/x2(j)) * factor ) 1134 y3(i) = dexp( dlog(x3(j)) + dlog(x3(j+1)/x3(j)) * factor ) 1135 end if 1136 1137 1 continue 1138 1139 return 1140 end 1141 1142 1143 c *** interhuntdp4veces.f *** 1144 1145 c *********************************************************************** 1146 1147 subroutine interhuntdp4veces ( y1,y2,y3,y4, zz,m, 1148 @ x1,x2,x3,x4, z,n, opt) 1149 1150 c interpolation soubroutine basada en Numerical Recipes HUNT.FOR 1151 c input values: x1(n),x2(n),x3(n),x4(n) at z(n) 1152 c output values: y1(m),y2(m),y3(m),y4(m) at zz(m) 1153 c options: 1 -> lineal 1154 c 2 -> logarithmic 1155 c *********************************************************************** 1156 1157 implicit none 1158 1159 ! Arguments 1160 integer n,m,opt ! I 1161 real*8 zz(m),z(n) ! I 1162 real*8 y1(m),y2(m),y3(m),y4(m) ! O 1163 real*8 x1(n),x2(n),x3(n),x4(n) ! I 1164 1165 1166 ! Local variables 1167 integer i, j 1168 real*8 factor 1169 real*8 zaux 1170 1171 !!!! 1172 1173 j = 1 ! initial first guess (=n/2 is anothr pssblty) 1174 1175 do 1,i=1,m ! 1176 1177 ! Caza del indice j donde ocurre que zz(i) esta entre [z(j),z(j+1)] 1178 zaux = zz(i) 1179 if (abs(zaux-z(1)).le.0.01d0) then 1180 zaux=z(1) 1181 elseif (abs(zaux-z(n)).le.0.01d0) then 1182 zaux=z(n) 1183 endif 1184 call huntdp ( z,n, zaux, j ) 1185 if ( j.eq.0 .or. j.eq.n ) then 1186 write (*,*) ' HUNT/ Limits input grid:', z(1),z(n) 1187 write (*,*) ' HUNT/ location in new grid:', zz(i) 1188 stop ' INTERHUNTDP4/ Interpolat error. zz out of limits.' 1189 endif 1190 1191 ! Perform interpolation 1192 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1193 if (opt.eq.1) then 1194 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 1195 y2(i) = x2(j) + (x2(j+1)-x2(j)) * factor 1196 y3(i) = x3(j) + (x3(j+1)-x3(j)) * factor 1197 y4(i) = x4(j) + (x4(j+1)-x4(j)) * factor 1198 else 1199 y1(i) = dexp( dlog(x1(j)) + dlog(x1(j+1)/x1(j)) * factor ) 1200 y2(i) = dexp( dlog(x2(j)) + dlog(x2(j+1)/x2(j)) * factor ) 1201 y3(i) = dexp( dlog(x3(j)) + dlog(x3(j+1)/x3(j)) * factor ) 1202 y4(i) = dexp( dlog(x4(j)) + dlog(x4(j+1)/x4(j)) * factor ) 1203 end if 1204 1205 1 continue 1206 1207 return 1208 end 1209 1210 1211 c *** interhuntdp.f *** 1212 1213 c *********************************************************************** 1214 1215 subroutine interhuntdp ( y1, zz,m, 1216 @ x1, z,n, opt) 1217 1218 c interpolation soubroutine basada en Numerical Recipes HUNT.FOR 1219 c input values: x1(n) at z(n) 1220 c output values: y1(m) at zz(m) 1221 c options: 1 -> lineal 1222 c 2 -> logarithmic 1223 c *********************************************************************** 1224 1225 implicit none 1226 1227 ! Arguments 1228 integer n,m,opt ! I 1229 real*8 zz(m),z(n) ! I 1230 real*8 y1(m) ! O 1231 real*8 x1(n) ! I 1232 1233 1234 ! Local variables 1235 integer i, j 1236 real*8 factor 1237 real*8 zaux 1238 1239 !!!! 1240 1241 j = 1 ! initial first guess (=n/2 is anothr pssblty) 1242 1243 do 1,i=1,m ! 1244 1245 ! Caza del indice j donde ocurre que zz(i) esta entre [z(j),z(j+1)] 1246 zaux = zz(i) 1247 if (abs(zaux-z(1)).le.0.01d0) then 1248 zaux=z(1) 1249 elseif (abs(zaux-z(n)).le.0.01d0) then 1250 zaux=z(n) 1251 endif 1252 call huntdp ( z,n, zaux, j ) 1253 if ( j.eq.0 .or. j.eq.n ) then 1254 write (*,*) ' HUNT/ Limits input grid:', z(1),z(n) 1255 write (*,*) ' HUNT/ location in new grid:', zz(i) 1256 stop ' INTERHUNT/ Interpolat error. zz out of limits.' 1257 endif 1258 1259 ! Perform interpolation 1260 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1261 if (opt.eq.1) then 1262 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 1263 else 1264 y1(i) = dexp( dlog(x1(j)) + dlog(x1(j+1)/x1(j)) * factor ) 1265 end if 1266 1267 1 continue 1268 1269 return 1270 end 1271 1272 1273 c *** interhunt.f *** 1274 1615 1275 c*********************************************************************** 1616 c tcrco2_subrut.f 1617 c 1618 c jan 98 malv version for mz1d. copied from solar10/mz4sub.f 1619 c jul 2011 malv+fgg adapted to LMD-MGCM 1276 1277 subroutine interhunt ( y1, zz,m, 1278 @ x1, z,n, opt) 1279 1280 c interpolation soubroutine basada en Numerical Recipes HUNT.FOR 1281 c input values: x1(n) at z(n) 1282 c output values: y1(m) at zz(m) 1283 c options: 1 -> lineal 1284 c 2 -> logarithmic 1620 1285 c*********************************************************************** 1621 1622 ************************************************************************ 1623 1624 subroutine dinterconnection ( v, vt ) 1625 1626 * input: vib. temp. from che*.for programs, vt(nl) 1627 * output: test vibrational temp. for other che*.for, v(nl) 1628 ! iconex_smooth=1 ==> with smoothing 1629 ! iconex_smooth=0 ==> without smoothing 1630 ! iconex_tk=40 ==> with forced lte up to 40 km 1631 ! iconex_tk=20 ==> with forced lte up to 20 km 1632 ************************************************************************ 1633 1634 implicit none 1635 include 'nlte_paramdef.h' 1636 include 'nlte_commons.h' 1637 1638 c argumentos 1639 real*8 vt(nl), v(nl) 1640 1641 c local variables 1642 integer i 1643 1644 c ************* 1645 1646 do i=1,nl 1647 v(i) = vt(i) 1648 end do 1649 1650 ! lo siguiente se utilizaba en solar10, pero es mejor introducirlo en 1651 ! la driver. por ahora no lo uso todavia. 1652 ! call fluctua(v,iconex_fluctua) 1653 ! call smooth_nl(v,iconex_smooth,nl) 1654 ! call forzar_tk(v,iconex_tk) 1655 1656 return 1657 end 1658 1286 1287 implicit none 1288 1289 ! Arguments 1290 integer n,m,opt ! I 1291 real zz(m),z(n) ! I 1292 real y1(m) ! O 1293 real x1(n) ! I 1294 1295 1296 ! Local variables 1297 integer i, j 1298 real factor 1299 real zaux 1300 1301 !!!! 1302 1303 j = 1 ! initial first guess (=n/2 is anothr pssblty) 1304 1305 do 1,i=1,m ! 1306 1307 ! Busca indice j donde ocurre q zz(i) esta entre [z(j),z(j+1)] 1308 zaux = zz(i) 1309 if (abs(zaux-z(1)).le.0.01) then 1310 zaux=z(1) 1311 elseif (abs(zaux-z(n)).le.0.01) then 1312 zaux=z(n) 1313 endif 1314 call hunt ( z,n, zaux, j ) 1315 if ( j.eq.0 .or. j.eq.n ) then 1316 write (*,*) ' HUNT/ Limits input grid:', z(1),z(n) 1317 write (*,*) ' HUNT/ location in new grid:', zz(i) 1318 stop ' interhunt/ Interpolat error. z out of limits.' 1319 endif 1320 1321 ! Perform interpolation 1322 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1323 if (opt.eq.1) then 1324 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 1325 else 1326 y1(i) = exp( log(x1(j)) + log(x1(j+1)/x1(j)) * factor ) 1327 end if 1328 1329 1330 1 continue 1331 1332 return 1333 end 1334 1335 1336 c *** interhuntlimits2veces.f *** 1337 1659 1338 c*********************************************************************** 1660 function planckdp(tp,xnu) 1661 c returns the black body function at wavenumber xnu and temperature t. 1339 1340 subroutine interhuntlimits2veces 1341 @ ( y1,y2, zz,m, limite1,limite2, 1342 @ x1,x2, z,n, opt) 1343 1344 c Interpolation soubroutine basada en Numerical Recipes HUNT.FOR 1345 c Input values: x1,x2(n) at z(n) 1346 c Output values: 1347 c y1,y2(m) at zz(m) pero solo entre los indices de zz 1348 c siguientes: [limite1,limite2] 1349 c Options: 1 -> linear in z and linear in x 1350 c 2 -> linear in z and logarithmic in x 1351 c 3 -> logarithmic in z and linear in x 1352 c 4 -> logarithmic in z and logaritmic in x 1353 c 1354 c NOTAS: Esta subrutina extiende y generaliza la usual 1355 c "interhunt5veces" en 2 direcciones: 1356 c - la condicion en los limites es que zz(limite1:limite2) 1357 c esté dentro de los limites de z (pero quizas no todo zz) 1358 c - se han añadido 3 opciones mas al caso de interpolacion 1359 c logaritmica, ahora se hace en log de z, de x o de ambos. 1360 c Notese que esta subrutina engloba a la interhunt5veces 1361 c ( esta es reproducible haciendo limite1=1 y limite2=m 1362 c y usando una de las 2 primeras opciones opt=1,2 ) 1662 1363 c*********************************************************************** 1663 1664 implicit none 1665 1666 include 'nlte_paramdef.h' 1667 include 'nlte_commons.h' 1668 1669 ! common/datis/ pi, vlight, ee, hplanck, gamma, ab, 1670 ! @ n_avog, GG, R0, cte_sb, kboltzman, raddeg 1671 ! real*8 pi, vlight, ee, hplanck, gamma, ab, 1672 ! @ n_avog, GG, R0, cte_sb, kboltzman, raddeg 1673 1674 real*8 planckdp 1675 real*8 xnu 1676 real tp 1677 1678 planckdp = gamma*xnu**3.0 / exp( ee*xnu/dble(tp) ) 1679 !erg cm-2.sr-1/cm-1. 1680 1681 return 1682 end 1683 1684 c **************************************************************** 1685 function bandid (ib) 1686 c returns the 2 character code of the band 1687 c **************************************************************** 1688 implicit none 1689 1690 integer ib 1691 character*2 bandid 1692 1693 132 format(i2) 1694 ! encode (2,132,bandid) ib 1695 write ( bandid, 132) ib 1696 1697 if ( ib .eq. 1 ) bandid = '01' 1698 if ( ib .eq. 2 ) bandid = '02' 1699 if ( ib .eq. 3 ) bandid = '03' 1700 if ( ib .eq. 4 ) bandid = '04' 1701 if ( ib .eq. 5 ) bandid = '05' 1702 if ( ib .eq. 6 ) bandid = '06' 1703 if ( ib .eq. 7 ) bandid = '07' 1704 if ( ib .eq. 8 ) bandid = '08' 1705 if ( ib .eq. 9 ) bandid = '09' 1706 if ( ib .eq. 0 ) bandid = '00' 1707 1708 c end 1709 return 1364 1365 implicit none 1366 1367 ! Arguments 1368 integer n,m,opt, limite1,limite2 ! I 1369 real zz(m),z(n) ! I 1370 real y1(m),y2(m) ! O 1371 real x1(n),x2(n) ! I 1372 1373 1374 ! Local variables 1375 integer i, j 1376 real factor 1377 real zaux 1378 1379 !!!! 1380 1381 j = 1 ! initial first guess (=n/2 is anothr pssblty) 1382 1383 do 1,i=limite1,limite2 1384 1385 ! Busca indice j donde ocurre q zz(i) esta entre [z(j),z(j+1)] 1386 zaux = zz(i) 1387 if (abs(zaux-z(1)).le.0.01) then 1388 zaux=z(1) 1389 elseif (abs(zaux-z(n)).le.0.01) then 1390 zaux=z(n) 1391 endif 1392 call hunt ( z,n, zaux, j ) 1393 if ( j.eq.0 .or. j.eq.n ) then 1394 write (*,*) ' HUNT/ Limits input grid:', z(1),z(n) 1395 write (*,*) ' HUNT/ location in new grid:', zz(i) 1396 stop ' interhuntlimits/ Interpolat error. z out of limits.' 1397 endif 1398 1399 ! Perform interpolation 1400 if (opt.eq.1) then 1401 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1402 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 1403 y2(i) = x2(j) + (x2(j+1)-x2(j)) * factor 1404 1405 elseif (opt.eq.2) then 1406 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1407 y1(i) = exp( log(x1(j)) + log(x1(j+1)/x1(j)) * factor ) 1408 y2(i) = exp( log(x2(j)) + log(x2(j+1)/x2(j)) * factor ) 1409 elseif (opt.eq.3) then 1410 factor = (log(zz(i))-log(z(j)))/(log(z(j+1))-log(z(j))) 1411 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 1412 y2(i) = x2(j) + (x2(j+1)-x2(j)) * factor 1413 elseif (opt.eq.4) then 1414 factor = (log(zz(i))-log(z(j)))/(log(z(j+1))-log(z(j))) 1415 y1(i) = exp( log(x1(j)) + log(x1(j+1)/x1(j)) * factor ) 1416 y2(i) = exp( log(x2(j)) + log(x2(j+1)/x2(j)) * factor ) 1417 end if 1418 1419 1420 1 continue 1421 1422 return 1423 end 1424 1425 1426 c *** interhuntlimits5veces.f *** 1427 1428 c*********************************************************************** 1429 1430 subroutine interhuntlimits5veces 1431 @ ( y1,y2,y3,y4,y5, zz,m, limite1,limite2, 1432 @ x1,x2,x3,x4,x5, z,n, opt) 1433 1434 c Interpolation soubroutine basada en Numerical Recipes HUNT.FOR 1435 c Input values: x1,x2,..,x5(n) at z(n) 1436 c Output values: 1437 c y1,y2,...,y5(m) at zz(m) pero solo entre los indices de zz 1438 c siguientes: [limite1,limite2] 1439 c Options: 1 -> linear in z and linear in x 1440 c 2 -> linear in z and logarithmic in x 1441 c 3 -> logarithmic in z and linear in x 1442 c 4 -> logarithmic in z and logaritmic in x 1443 c 1444 c NOTAS: Esta subrutina extiende y generaliza la usual 1445 c "interhunt5veces" en 2 direcciones: 1446 c - la condicion en los limites es que zz(limite1:limite2) 1447 c esté dentro de los limites de z (pero quizas no todo zz) 1448 c - se han añadido 3 opciones mas al caso de interpolacion 1449 c logaritmica, ahora se hace en log de z, de x o de ambos. 1450 c Notese que esta subrutina engloba a la interhunt5veces 1451 c ( esta es reproducible haciendo limite1=1 y limite2=m 1452 c y usando una de las 2 primeras opciones opt=1,2 ) 1453 c*********************************************************************** 1454 1455 implicit none 1456 1457 ! Arguments 1458 integer n,m,opt, limite1,limite2 ! I 1459 real zz(m),z(n) ! I 1460 real y1(m),y2(m),y3(m),y4(m),y5(m) ! O 1461 real x1(n),x2(n),x3(n),x4(n),x5(n) ! I 1462 1463 1464 ! Local variables 1465 integer i, j 1466 real factor 1467 real zaux 1468 1469 !!!! 1470 1471 j = 1 ! initial first guess (=n/2 is anothr pssblty) 1472 1473 do 1,i=limite1,limite2 1474 1475 ! Busca indice j donde ocurre q zz(i) esta entre [z(j),z(j+1)] 1476 zaux = zz(i) 1477 if (abs(zaux-z(1)).le.0.01) then 1478 zaux=z(1) 1479 elseif (abs(zaux-z(n)).le.0.01) then 1480 zaux=z(n) 1481 endif 1482 call hunt ( z,n, zaux, j ) 1483 if ( j.eq.0 .or. j.eq.n ) then 1484 write (*,*) ' HUNT/ Limits input grid:', z(1),z(n) 1485 write (*,*) ' HUNT/ location in new grid:', zz(i) 1486 stop ' interhuntlimits/ Interpolat error. z out of limits.' 1487 endif 1488 1489 ! Perform interpolation 1490 if (opt.eq.1) then 1491 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1492 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 1493 y2(i) = x2(j) + (x2(j+1)-x2(j)) * factor 1494 y3(i) = x3(j) + (x3(j+1)-x3(j)) * factor 1495 y4(i) = x4(j) + (x4(j+1)-x4(j)) * factor 1496 y5(i) = x5(j) + (x5(j+1)-x5(j)) * factor 1497 elseif (opt.eq.2) then 1498 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1499 y1(i) = exp( log(x1(j)) + log(x1(j+1)/x1(j)) * factor ) 1500 y2(i) = exp( log(x2(j)) + log(x2(j+1)/x2(j)) * factor ) 1501 y3(i) = exp( log(x3(j)) + log(x3(j+1)/x3(j)) * factor ) 1502 y4(i) = exp( log(x4(j)) + log(x4(j+1)/x4(j)) * factor ) 1503 y5(i) = exp( log(x5(j)) + log(x5(j+1)/x5(j)) * factor ) 1504 elseif (opt.eq.3) then 1505 factor = (log(zz(i))-log(z(j)))/(log(z(j+1))-log(z(j))) 1506 y1(i) = x1(j) + (x1(j+1)-x1(j)) * factor 1507 y2(i) = x2(j) + (x2(j+1)-x2(j)) * factor 1508 y3(i) = x3(j) + (x3(j+1)-x3(j)) * factor 1509 y4(i) = x4(j) + (x4(j+1)-x4(j)) * factor 1510 y5(i) = x5(j) + (x5(j+1)-x5(j)) * factor 1511 elseif (opt.eq.4) then 1512 factor = (log(zz(i))-log(z(j)))/(log(z(j+1))-log(z(j))) 1513 y1(i) = exp( log(x1(j)) + log(x1(j+1)/x1(j)) * factor ) 1514 y2(i) = exp( log(x2(j)) + log(x2(j+1)/x2(j)) * factor ) 1515 y3(i) = exp( log(x3(j)) + log(x3(j+1)/x3(j)) * factor ) 1516 y4(i) = exp( log(x4(j)) + log(x4(j+1)/x4(j)) * factor ) 1517 y5(i) = exp( log(x5(j)) + log(x5(j+1)/x5(j)) * factor ) 1518 end if 1519 1520 1521 1 continue 1522 1523 return 1524 end 1525 1526 1527 1528 c *** interhuntlimits.f *** 1529 1530 c*********************************************************************** 1531 1532 subroutine interhuntlimits ( y, zz,m, limite1,limite2, 1533 @ x, z,n, opt) 1534 1535 c Interpolation soubroutine basada en Numerical Recipes HUNT.FOR 1536 c Input values: x(n) at z(n) 1537 c Output values: y(m) at zz(m) pero solo entre los indices de zz 1538 c siguientes: [limite1,limite2] 1539 c Options: 1 -> linear in z and linear in x 1540 c 2 -> linear in z and logarithmic in x 1541 c 3 -> logarithmic in z and linear in x 1542 c 4 -> logarithmic in z and logaritmic in x 1543 c 1544 c NOTAS: Esta subrutina extiende y generaliza la usual "interhunt" 1545 c en 2 direcciones: 1546 c - la condicion en los limites es que zz(limite1:limite2) 1547 c esté dentro de los limites de z (pero quizas no todo zz) 1548 c - se han añadido 3 opciones mas al caso de interpolacion 1549 c logaritmica, ahora se hace en log de z, de x o de ambos. 1550 c Notese que esta subrutina engloba a la usual interhunt 1551 c ( esta es reproducible haciendo limite1=1 y limite2=m 1552 c y usando una de las 2 primeras opciones opt=1,2 ) 1553 c*********************************************************************** 1554 1555 implicit none 1556 1557 ! Arguments 1558 integer n,m,opt, limite1,limite2 ! I 1559 real zz(m),z(n) ! I 1560 real y(m) ! O 1561 real x(n) ! I 1562 1563 1564 ! Local variables 1565 integer i, j 1566 real factor 1567 real zaux 1568 1569 !!!! 1570 1571 j = 1 ! initial first guess (=n/2 is anothr pssblty) 1572 1573 do 1,i=limite1,limite2 1574 1575 ! Busca indice j donde ocurre q zz(i) esta entre [z(j),z(j+1)] 1576 zaux = zz(i) 1577 if (abs(zaux-z(1)).le.0.01) then 1578 zaux=z(1) 1579 elseif (abs(zaux-z(n)).le.0.01) then 1580 zaux=z(n) 1581 endif 1582 call hunt ( z,n, zaux, j ) 1583 if ( j.eq.0 .or. j.eq.n ) then 1584 write (*,*) ' HUNT/ Limits input grid:', z(1),z(n) 1585 write (*,*) ' HUNT/ location in new grid:', zz(i) 1586 stop ' interhuntlimits/ Interpolat error. z out of limits.' 1587 endif 1588 1589 ! Perform interpolation 1590 if (opt.eq.1) then 1591 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1592 y(i) = x(j) + (x(j+1)-x(j)) * factor 1593 elseif (opt.eq.2) then 1594 factor = (zz(i)-z(j))/(z(j+1)-z(j)) 1595 y(i) = exp( log(x(j)) + log(x(j+1)/x(j)) * factor ) 1596 elseif (opt.eq.3) then 1597 factor = (log(zz(i))-log(z(j)))/(log(z(j+1))-log(z(j))) 1598 y(i) = x(j) + (x(j+1)-x(j)) * factor 1599 elseif (opt.eq.4) then 1600 factor = (log(zz(i))-log(z(j)))/(log(z(j+1))-log(z(j))) 1601 y(i) = exp( log(x(j)) + log(x(j+1)/x(j)) * factor ) 1602 end if 1603 1604 1605 1 continue 1606 1607 return 1608 end 1609 1610 1611 c *** lubksb_dp.f *** 1612 1613 subroutine lubksb_dp(a,n,np,indx,b) 1614 1615 implicit none 1616 1617 integer,intent(in) :: n,np 1618 real*8,intent(in) :: a(np,np) 1619 integer,intent(in) :: indx(n) 1620 real*8,intent(out) :: b(n) 1621 1622 real*8 sum 1623 integer ii, ll, i, j 1624 1625 ii=0 1626 do 12 i=1,n 1627 ll=indx(i) 1628 sum=b(ll) 1629 b(ll)=b(i) 1630 if (ii.ne.0)then 1631 do 11 j=ii,i-1 1632 sum=sum-a(i,j)*b(j) 1633 11 continue 1634 else if (sum.ne.0.0) then 1635 ii=i 1636 endif 1637 b(i)=sum 1638 12 continue 1639 do 14 i=n,1,-1 1640 sum=b(i) 1641 if(i.lt.n)then 1642 do 13 j=i+1,n 1643 sum=sum-a(i,j)*b(j) 1644 13 continue 1645 endif 1646 b(i)=sum/a(i,i) 1647 14 continue 1648 return 1649 end 1650 1651 1652 c *** ludcmp_dp.f *** 1653 1654 subroutine ludcmp_dp(a,n,np,indx,d) 1655 1656 implicit none 1657 1658 integer,intent(in) :: n, np 1659 real*8,intent(inout) :: a(np,np) 1660 real*8,intent(out) :: d 1661 integer,intent(out) :: indx(n) 1662 1663 integer nmax, i, j, k, imax 1664 real*8 tiny 1665 parameter (nmax=100,tiny=1.0d-20) 1666 real*8 vv(nmax), aamax, sum, dum 1667 1668 1669 d=1.0d0 1670 do 12 i=1,n 1671 aamax=0.0d0 1672 do 11 j=1,n 1673 if (abs(a(i,j)).gt.aamax) aamax=abs(a(i,j)) 1674 11 continue 1675 if (aamax.eq.0.0) then 1676 write(*,*) 'ludcmp_dp: singular matrix!' 1677 stop 1678 endif 1679 vv(i)=1.0d0/aamax 1680 12 continue 1681 do 19 j=1,n 1682 if (j.gt.1) then 1683 do 14 i=1,j-1 1684 sum=a(i,j) 1685 if (i.gt.1)then 1686 do 13 k=1,i-1 1687 sum=sum-a(i,k)*a(k,j) 1688 13 continue 1689 a(i,j)=sum 1690 endif 1691 14 continue 1692 endif 1693 aamax=0.0d0 1694 do 16 i=j,n 1695 sum=a(i,j) 1696 if (j.gt.1)then 1697 do 15 k=1,j-1 1698 sum=sum-a(i,k)*a(k,j) 1699 15 continue 1700 a(i,j)=sum 1701 endif 1702 dum=vv(i)*abs(sum) 1703 if (dum.ge.aamax) then 1704 imax=i 1705 aamax=dum 1706 endif 1707 16 continue 1708 if (j.ne.imax)then 1709 do 17 k=1,n 1710 dum=a(imax,k) 1711 a(imax,k)=a(j,k) 1712 a(j,k)=dum 1713 17 continue 1714 d=-d 1715 vv(imax)=vv(j) 1716 endif 1717 indx(j)=imax 1718 if(j.ne.n)then 1719 if(a(j,j).eq.0.0)a(j,j)=tiny 1720 dum=1.0d0/a(j,j) 1721 do 18 i=j+1,n 1722 a(i,j)=a(i,j)*dum 1723 18 continue 1724 endif 1725 19 continue 1726 if(a(n,n).eq.0.0)a(n,n)=tiny 1727 return 1710 1728 end 1711 1729 1712 1730 1713 1714 c***************************************************************************** 1715 c Subroutines previously included in mat_oper.F 1716 c***************************************************************************** 1717 c set of subroutines for the cz*.for programs: 1718 ! subroutine unit(a,n) 1719 ! subroutine diago(a,v,n) diagonal matrix with v 1720 ! subroutine invdiag(a,b,n) inverse of diagonal matrix 1721 ! subroutine sypvvv(a,b,c,d,n) suma y prod de 3 vectores, muy comun 1722 ! subroutine sypvmv(v,w,b,u,n) suma y prod de 3 vectores, muy comun 1723 ! subroutine mulmvv(w,b,u,v,n) prod matriz vector vector 1724 ! subroutine muymvv(w,b,u,v,n) prod matriz (inv.vector) vector 1725 ! subroutine samem (a,m,n) 1726 ! subroutine mulmv(a,b,c,n) 1727 ! subroutine mulmm(a,b,c,n) 1728 ! subroutine resmm(a,b,c,n) 1729 ! subroutine mulvv(a,b,c,n) 1730 ! subroutine sumvv(a,b,c,n) 1731 ! subroutine zerom(a,n) 1732 ! subroutine zero4m(a,b,c,d,n) 1733 ! subroutine zero3m(a,b,c,n) 1734 ! subroutine zero2m(a,b,n) 1735 ! subroutine zerov(a,n) 1736 ! subroutine zero4v(a,b,c,d,n) 1737 ! subroutine zero3v(a,b,c,n) 1738 ! subroutine zero2v(a,b,n) 1739 1740 ! 1741 ! 1742 ! May-05 Sustituimos todos los zerojt de cristina por las subrutinas 1743 ! genericas zerov*** 1744 ! 1731 c *** LUdec.f *** 1732 1733 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1734 c 1735 c Solution of linear equation without inverting matrix 1736 c using LU decomposition: 1737 c AA * xx = bb AA, bb: known 1738 c xx: to be found 1739 c AA and bb are not modified in this subroutine 1740 c 1741 c MALV , Sep 2007 1742 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1743 1744 subroutine LUdec(xx,aa,bb,m,n) 1745 1746 implicit none 1747 1748 ! Arguments 1749 integer,intent(in) :: m, n 1750 real*8,intent(in) :: aa(m,m), bb(m) 1751 real*8,intent(out) :: xx(m) 1752 1753 1754 ! Local variables 1755 real*8 a(n,n), b(n), x(n), d 1756 integer i, j, indx(n) 1757 1758 1759 ! Subrutinas utilizadas 1760 ! ludcmp_dp, lubksb_dp 1761 1762 !!!!!!!!!!!!!!!Comienza el programa !!!!!!!!!!!!!! 1763 1764 do i=1,n 1765 b(i) = bb(i+1) 1766 do j=1,n 1767 a(i,j) = aa(i+1,j+1) 1768 enddo 1769 enddo 1770 1771 ! Descomposicion de auxm1 1772 call ludcmp_dp ( a, n, n, indx, d) 1773 1774 ! Sustituciones foward y backwards para hallar la solucion 1775 do i=1,n 1776 x(i) = b(i) 1777 enddo 1778 call lubksb_dp( a, n, n, indx, x ) 1779 1780 do i=1,n 1781 xx(i+1) = x(i) 1782 enddo 1783 1784 return 1785 end 1786 1787 1788 c *** mat_oper.f *** 1789 1790 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 1791 1745 1792 c *********************************************************************** 1746 1793 subroutine unit(a,n) 1747 1794 c store the unit value in the diagonal of a 1748 1795 c *********************************************************************** 1796 implicit none 1749 1797 real*8 a(n,n) 1750 1798 integer n,i,j,k … … 1795 1843 1796 1844 c *********************************************************************** 1845 subroutine invdiag(a,b,n) 1846 c inverse of a diagonal matrix 1847 c *********************************************************************** 1848 implicit none 1849 1850 integer n,i,j,k 1851 real*8 a(n,n),b(n,n) 1852 1853 do 1,i=2,n-1 1854 do 2,j=2,n-1 1855 if (i.eq.j) then 1856 a(i,j) = 1.d0/b(i,i) 1857 else 1858 a(i,j)=0.0d0 1859 end if 1860 2 continue 1861 1 continue 1862 do k=1,n 1863 a(n,k) = 0.0d0 1864 a(1,k) = 0.0d0 1865 a(k,1) = 0.0d0 1866 a(k,n) = 0.0d0 1867 end do 1868 return 1869 end 1870 1871 1872 c *********************************************************************** 1797 1873 subroutine samem (a,m,n) 1798 1874 c store the matrix m in the matrix a 1799 1875 c *********************************************************************** 1876 implicit none 1800 1877 real*8 a(n,n),m(n,n) 1801 1878 integer n,i,j,k … … 1813 1890 return 1814 1891 end 1892 1893 1815 1894 c *********************************************************************** 1816 1895 subroutine mulmv(a,b,c,n) … … 1825 1904 sum=0.0d0 1826 1905 do 2,j=2,n-1 1827 sum =sum+ (b(i,j)) * (c(j))1906 sum = sum + b(i,j) * c(j) 1828 1907 2 continue 1829 1908 a(i)=sum … … 1834 1913 end 1835 1914 1836 c *********************************************************************** 1837 subroutine mulmm(a,b,c,n) 1838 c *********************************************************************** 1839 real*8 a(n,n), b(n,n), c(n,n) 1915 1916 c *********************************************************************** 1917 subroutine trucodiag(a,b,c,d,e,n) 1918 c inputs: matrices b,c,d,e 1919 c output: matriz diagonal a 1920 c Operacion a realizar: a = b * c^(-1) * d + e 1921 c La matriz c va a ser invertida 1922 c Todas las matrices de entrada son diagonales excepto b 1923 c Aprovechamos esa condicion para invertir c, acelerar el calculo, y 1924 c ademas, para forzar que a sea diagonal 1925 c *********************************************************************** 1926 implicit none 1927 real*8 a(n,n),b(n,n),c(n,n),d(n,n),e(n,n), sum 1840 1928 integer n,i,j,k 1841 1842 ! do i=2,n-1 1843 ! do j=2,n-1 1844 ! a(i,j)= 0.d00 1845 ! do k=2,n-1 1846 ! a(i,j) = a(i,j) + b(i,k) * c(k,j) 1847 ! end do 1848 ! end do 1849 ! end do 1850 do j=2,n-1 1851 do i=2,n-1 1852 a(i,j)=0.d0 1853 enddo 1854 do k=2,n-1 1855 do i=2,n-1 1856 a(i,j)=a(i,j)+b(i,k)*c(k,j) 1857 enddo 1858 enddo 1859 enddo 1929 do 1,i=2,n-1 1930 sum=0.0d0 1931 do 2,j=2,n-1 1932 sum=sum+ b(i,j) * d(j,j)/c(j,j) 1933 2 continue 1934 a(i,i) = sum + e(i,i) 1935 1 continue 1860 1936 do k=1,n 1861 1937 a(n,k) = 0.0d0 … … 1864 1940 a(k,n) = 0.0d0 1865 1941 end do 1866 1867 return 1868 end 1869 1870 c *********************************************************************** 1871 subroutine resmm(a,b,c,n) 1872 c *********************************************************************** 1873 real*8 a(n,n), b(n,n), c(n,n) 1874 integer n,i,j,k 1875 1876 do i=2,n-1 1877 do j=2,n-1 1878 a(i,j)= b(i,j) - c(i,j) 1879 end do 1880 end do 1881 do k=1,n 1882 a(n,k) = 0.0d0 1883 a(1,k) = 0.0d0 1884 a(k,1) = 0.0d0 1885 a(k,n) = 0.0d0 1886 end do 1887 1888 return 1889 end 1942 return 1943 end 1944 1945 1946 c *********************************************************************** 1947 subroutine trucommvv(v,b,c,u,w,n) 1948 c inputs: matrices b,c , vectores u,w 1949 c output: vector v 1950 c Operacion a realizar: v = b * c^(-1) * u + w 1951 c La matriz c va a ser invertida 1952 c c es diagonal, b no 1953 c Aprovechamos esa condicion para invertir c, y acelerar el calculo 1954 c *********************************************************************** 1955 implicit none 1956 real*8 v(n),b(n,n),c(n,n),u(n),w(n), sum 1957 integer n,i,j 1958 do 1,i=2,n-1 1959 sum=0.0d0 1960 do 2,j=2,n-1 1961 sum=sum+ b(i,j) * u(j)/c(j,j) 1962 2 continue 1963 v(i) = sum + w(i) 1964 1 continue 1965 v(1) = 0.d0 1966 v(n) = 0.d0 1967 return 1968 end 1969 1970 1971 c *********************************************************************** 1972 subroutine sypvmv(v,u,c,w,n) 1973 c inputs: matriz diagonal c , vectores u,w 1974 c output: vector v 1975 c Operacion a realizar: v = u + c * w 1976 c *********************************************************************** 1977 implicit none 1978 real*8 v(n),u(n),c(n,n),w(n) 1979 integer n,i 1980 do 1,i=2,n-1 1981 v(i)= u(i) + c(i,i) * w(i) 1982 1 continue 1983 v(1) = 0.0d0 1984 v(n) = 0.0d0 1985 return 1986 end 1987 1890 1988 1891 1989 c *********************************************************************** … … 1899 1997 1900 1998 do 1,i=2,n-1 1901 a(i)= (b(i)) + (c(i))1999 a(i)= b(i) + c(i) 1902 2000 1 continue 1903 2001 a(1) = 0.0d0 … … 1906 2004 end 1907 2005 1908 c *********************************************************************** 1909 subroutine zerom(a,n) 2006 2007 c *********************************************************************** 2008 subroutine sypvvv(a,b,c,d,n) 2009 c a(i)=b(i)+c(i)*d(i) 2010 c *********************************************************************** 2011 implicit none 2012 real*8 a(n),b(n),c(n),d(n) 2013 integer n,i 2014 do 1,i=2,n-1 2015 a(i)= b(i) + c(i) * d(i) 2016 1 continue 2017 a(1) = 0.0d0 2018 a(n) = 0.0d0 2019 return 2020 end 2021 2022 2023 c *********************************************************************** 2024 ! subroutine zerom(a,n) 1910 2025 c a(i,j)= 0.0 1911 2026 c *********************************************************************** 1912 1913 implicit none 1914 1915 integer n,i,j 1916 real*8 a(n,n) 1917 1918 do 1,i=1,n 1919 do 2,j=1,n 1920 a(i,j) = 0.0d0 1921 2 continue 1922 1 continue 1923 return 1924 end 2027 ! implicit none 2028 ! integer n,i,j 2029 ! real*8 a(n,n) 2030 2031 ! do 1,i=1,n 2032 ! do 2,j=1,n 2033 ! a(i,j) = 0.0d0 2034 ! 2 continue 2035 ! 1 continue 2036 ! return 2037 ! end 2038 1925 2039 1926 2040 c *********************************************************************** … … 1928 2042 c a(i,j) = b(i,j) = c(i,j) = d(i,j) = 0.0 1929 2043 c *********************************************************************** 2044 implicit none 1930 2045 real*8 a(n,n), b(n,n), c(n,n), d(n,n) 1931 integer n,i,j 1932 do 1,i=1,n 1933 do 2,j=1,n 1934 a(i,j) = 0.0d0 1935 b(i,j) = 0.0d0 1936 c(i,j) = 0.0d0 1937 d(i,j) = 0.0d0 1938 2 continue 1939 1 continue 1940 return 1941 end 2046 integer n 2047 a(1:n,1:n)=0.d0 2048 b(1:n,1:n)=0.d0 2049 c(1:n,1:n)=0.d0 2050 d(1:n,1:n)=0.d0 2051 ! do 1,i=1,n 2052 ! do 2,j=1,n 2053 ! a(i,j) = 0.0d0 2054 ! b(i,j) = 0.0d0 2055 ! c(i,j) = 0.0d0 2056 ! d(i,j) = 0.0d0 2057 ! 2 continue 2058 ! 1 continue 2059 return 2060 end 2061 1942 2062 1943 2063 c *********************************************************************** … … 1945 2065 c a(i,j) = b(i,j) = c(i,j) = 0.0 1946 2066 c ********************************************************************** 2067 implicit none 1947 2068 real*8 a(n,n), b(n,n), c(n,n) 1948 integer n,i,j 1949 do 1,i=1,n 1950 do 2,j=1,n 1951 a(i,j) = 0.0d0 1952 b(i,j) = 0.0d0 1953 c(i,j) = 0.0d0 1954 2 continue 1955 1 continue 1956 return 1957 end 2069 integer n 2070 a(1:n,1:n)=0.d0 2071 b(1:n,1:n)=0.d0 2072 c(1:n,1:n)=0.d0 2073 ! do 1,i=1,n 2074 ! do 2,j=1,n 2075 ! a(i,j) = 0.0d0 2076 ! b(i,j) = 0.0d0 2077 ! c(i,j) = 0.0d0 2078 ! 2 continue 2079 ! 1 continue 2080 return 2081 end 2082 1958 2083 1959 2084 c *********************************************************************** … … 1961 2086 c a(i,j) = b(i,j) = 0.0 1962 2087 c *********************************************************************** 2088 implicit none 1963 2089 real*8 a(n,n), b(n,n) 1964 integer n,i,j 1965 do 1,i=1,n 1966 do 2,j=1,n 1967 a(i,j) = 0.0d0 1968 b(i,j) = 0.0d0 1969 2 continue 1970 1 continue 1971 return 1972 end 1973 c *********************************************************************** 1974 subroutine zerov(a,n) 2090 integer n 2091 a(1:n,1:n)=0.d0 2092 b(1:n,1:n)=0.d0 2093 ! do 1,i=1,n 2094 ! do 2,j=1,n 2095 ! a(i,j) = 0.0d0 2096 ! b(i,j) = 0.0d0 2097 ! 2 continue 2098 ! 1 continue 2099 return 2100 end 2101 2102 2103 c *********************************************************************** 2104 ! subroutine zerov(a,n) 1975 2105 c a(i)= 0.0 1976 2106 c *********************************************************************** 1977 real*8 a(n) 1978 integer n,i 1979 do 1,i=1,n 1980 a(i) = 0.0d0 1981 1 continue 1982 return 1983 end 2107 ! implicit none 2108 ! real*8 a(n) 2109 ! integer n,i 2110 ! do 1,i=1,n 2111 ! a(i) = 0.0d0 2112 ! 1 continue 2113 ! return 2114 ! end 2115 2116 1984 2117 c *********************************************************************** 1985 2118 subroutine zero4v(a,b,c,d,n) 1986 2119 c a(i) = b(i) = c(i) = d(i,j) = 0.0 1987 2120 c *********************************************************************** 2121 implicit none 1988 2122 real*8 a(n), b(n), c(n), d(n) 1989 integer n,i 1990 do 1,i=1,n 1991 a(i) = 0.0d0 1992 b(i) = 0.0d0 1993 c(i) = 0.0d0 1994 d(i) = 0.0d0 1995 1 continue 1996 return 1997 end 2123 integer n 2124 a(1:n)=0.d0 2125 b(1:n)=0.d0 2126 c(1:n)=0.d0 2127 d(1:n)=0.d0 2128 ! do 1,i=1,n 2129 ! a(i) = 0.0d0 2130 ! b(i) = 0.0d0 2131 ! c(i) = 0.0d0 2132 ! d(i) = 0.0d0 2133 ! 1 continue 2134 return 2135 end 2136 2137 1998 2138 c *********************************************************************** 1999 2139 subroutine zero3v(a,b,c,n) 2000 2140 c a(i) = b(i) = c(i) = 0.0 2001 2141 c *********************************************************************** 2142 implicit none 2002 2143 real*8 a(n), b(n), c(n) 2003 integer n,i 2004 do 1,i=1,n 2005 a(i) = 0.0d0 2006 b(i) = 0.0d0 2007 c(i) = 0.0d0 2008 1 continue 2009 return 2010 end 2144 integer n 2145 a(1:n)=0.d0 2146 b(1:n)=0.d0 2147 c(1:n)=0.d0 2148 ! do 1,i=1,n 2149 ! a(i) = 0.0d0 2150 ! b(i) = 0.0d0 2151 ! c(i) = 0.0d0 2152 ! 1 continue 2153 return 2154 end 2155 2156 2011 2157 c *********************************************************************** 2012 2158 subroutine zero2v(a,b,n) 2013 2159 c a(i) = b(i) = 0.0 2014 2160 c *********************************************************************** 2161 implicit none 2015 2162 real*8 a(n), b(n) 2016 integer n,i 2017 do 1,i=1,n 2018 a(i) = 0.0d0 2019 b(i) = 0.0d0 2020 1 continue 2021 return 2022 end 2023 2024 2163 integer n 2164 a(1:n)=0.d0 2165 b(1:n)=0.d0 2166 ! do 1,i=1,n 2167 ! a(i) = 0.0d0 2168 ! b(i) = 0.0d0 2169 ! 1 continue 2170 return 2171 end 2172 2173 c *********************************************************************** 2174 2175 2176 c**************************************************************************** 2177 2178 c *** suaviza.f *** 2179 2180 c***************************************************************************** 2181 c 2182 subroutine suaviza ( x, n, ismooth, y ) 2183 c 2184 c x - input and return values 2185 c y - auxiliary vector 2186 c ismooth = 0 --> no smoothing is performed 2187 c ismooth = 1 --> weak smoothing (5 points, centred weighted) 2188 c ismooth = 2 --> normal smoothing (3 points, evenly weighted) 2189 c ismooth = 3 --> strong smoothing (5 points, evenly weighted) 2190 2191 2192 c august 1991 2193 c***************************************************************************** 2194 2195 implicit none 2196 2197 integer n, imax, imin, i, ismooth 2198 real*8 x(n), y(n) 2199 c***************************************************************************** 2200 2201 imin=1 2202 imax=n 2203 2204 if (ismooth.eq.0) then 2205 2206 return 2207 2208 elseif (ismooth.eq.1) then ! 5 points, with central weighting 2209 2210 do i=imin,imax 2211 if(i.eq.imin)then 2212 y(i)=x(imin) 2213 elseif(i.eq.imax)then 2214 y(i)=x(imax-1)+(x(imax-1)-x(imax-3))/2.d0 2215 elseif(i.gt.(imin+1) .and. i.lt.(imax-1) )then 2216 y(i) = ( x(i+2)/4.d0 + x(i+1)/2.d0 + 2.d0*x(i)/3.d0 + 2217 @ x(i-1)/2.d0 + x(i-2)/4.d0 )* 6.d0/13.d0 2218 else 2219 y(i)=(x(i+1)/2.d0+x(i)+x(i-1)/2.d0)/2.d0 2220 end if 2221 end do 2222 2223 elseif (ismooth.eq.2) then ! 3 points, evenly spaced 2224 2225 do i=imin,imax 2226 if(i.eq.imin)then 2227 y(i)=x(imin) 2228 elseif(i.eq.imax)then 2229 y(i)=x(imax-1)+(x(imax-1)-x(imax-3))/2.d0 2230 else 2231 y(i) = ( x(i+1)+x(i)+x(i-1) )/3.d0 2232 end if 2233 end do 2234 2235 elseif (ismooth.eq.3) then ! 5 points, evenly spaced 2236 2237 do i=imin,imax 2238 if(i.eq.imin)then 2239 y(i) = x(imin) 2240 elseif(i.eq.(imin+1) .or. i.eq.(imax-1))then 2241 y(i) = ( x(i+1)+x(i)+x(i-1) )/3.d0 2242 elseif(i.eq.imax)then 2243 y(i) = ( x(imax-1) + x(imax-1) + x(imax-2) ) / 3.d0 2244 else 2245 y(i) = ( x(i+2)+x(i+1)+x(i)+x(i-1)+x(i-2) )/5.d0 2246 end if 2247 end do 2248 2249 else 2250 2251 write (*,*) ' Error in suaviza.f Wrong ismooth value.' 2252 stop 2253 2254 endif 2255 2256 c rehago el cambio, para devolver x(i) 2257 do i=imin,imax 2258 x(i)=y(i) 2259 end do 2260 2261 return 2262 end 2263 2264 2265 c *********************************************************************** 2266 subroutine mulmmf90(a,b,c,n) 2267 c *********************************************************************** 2268 implicit none 2269 real*8 a(n,n), b(n,n), c(n,n) 2270 integer n 2271 2272 a=matmul(b,c) 2273 a(1,:)=0.d0 2274 a(:,1)=0.d0 2275 a(n,:)=0.d0 2276 a(:,n)=0.d0 2277 2278 return 2279 end 2280 2281 2282 c *********************************************************************** 2283 subroutine resmmf90(a,b,c,n) 2284 c *********************************************************************** 2285 implicit none 2286 real*8 a(n,n), b(n,n), c(n,n) 2287 integer n 2288 2289 a=b-c 2290 a(1,:)=0.d0 2291 a(:,1)=0.d0 2292 a(n,:)=0.d0 2293 a(:,n)=0.d0 2294 2295 return 2296 end 2297 2298 2299 c******************************************************************* 2300 2301 subroutine gethist_03 (ihist) 2302 2303 c******************************************************************* 2304 2305 implicit none 2306 2307 include 'nlte_paramdef.h' 2308 include 'nlte_commons.h' 2309 2310 2311 c arguments 2312 integer ihist 2313 2314 c local variables 2315 integer j, r, mm 2316 real*8 xx 2317 2318 c *************** 2319 2320 nbox = nbox_stored(ihist) 2321 do j=1,mm_stored(ihist) 2322 thist(j) = thist_stored(ihist,j) 2323 do r=1,nbox_stored(ihist) 2324 no(r) = no_stored(ihist,r) 2325 sk1(j,r) = sk1_stored(ihist,j,r) 2326 xls1(j,r) = xls1_stored(ihist,j,r) 2327 xld1(j,r) = xld1_stored(ihist,j,r) 2328 enddo 2329 enddo 2330 2331 2332 return 2333 end 2334 2335 2336 c ******************************************************************* 2337 2338 subroutine rhist_03 (ihist) 2339 2340 c ******************************************************************* 2341 2342 implicit none 2343 2344 include 'nlte_paramdef.h' 2345 include 'nlte_commons.h' 2346 2347 2348 c arguments 2349 integer ihist 2350 2351 c local variables 2352 integer j, r, mm 2353 real*8 xx 2354 2355 c *************** 2356 2357 open(unit=3,file=hisfile,status='old') 2358 2359 read(3,*) 2360 read(3,*) 2361 read(3,*) mm_stored(ihist) 2362 read(3,*) 2363 read(3,*) nbox_stored(ihist) 2364 read(3,*) 2365 2366 if ( nbox_stored(ihist) .gt. nbox_max ) then 2367 write (*,*) ' nbox too large in input file ', hisfile 2368 stop ' Check maximum number nbox_max in mz1d.par ' 2369 endif 2370 2371 do j=1,mm_stored(ihist) 2372 read(3,*) thist_stored(ihist,j) 2373 do r=1,nbox_stored(ihist) 2374 read(3,*) no_stored(ihist,r), 2375 & sk1_stored(ihist,j,r), 2376 & xls1_stored(ihist,j,r), 2377 & xx, 2378 & xld1_stored(ihist,j,r) 2379 enddo 2380 2381 enddo 2382 2383 close(unit=3) 2384 2385 2386 return 2387 end
Note: See TracChangeset
for help on using the changeset viewer.