Advertisement
Guest User

Global areal average including pole

a guest
Nov 12th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. !______________________________________________________________________________________
  2. !                                            
  3. ! Original Programmer : Taufiq Hassan                            
  4. ! Creation Date : Aug. 15, 2014                                
  5. ! Last Update : Sep. 1, 2014 (by Taufiq)                           
  6. !======================================================================================!
  7. ! This Program will read a T42 gridded binary file and extract any variable within.    !
  8. ! It will calcuLATe the global average of any variable with LATitude weighting.        !           !
  9. ! To account for missing AREA around the poles, I had to give extra weighting to       !
  10. ! the first (LAT=-87.8638) and the last (LAT=87.8638) LATitude values.             !
  11. !======================================================================================!
  12. program convert
  13. implicit none
  14. !_______________________Variable Declaration_________________________________________!
  15. real, parameter :: UNDEF = -9999.0, pi=3.14159265
  16. integer,parameter::NX=128,NY=64,NZ=1,NT=12,NV=4,NS=0
  17. character*120 :: name
  18. integer:: j,k,i
  19. real:: OTOA(NX,NY),TOA(NX,NY),SUMLON(NY),LON_AVG(NY),LAT(NY),AREA(NY),DIFF(NX,NY),SUMM(NX,NY),TIME_AVG(NX,NY)
  20. real:: top,btm,true_avg,L,ratio
  21. !____________________________________________________________________________________!
  22. !==================Opening and retreiving variable===================================!
  23. do i=75,100
  24.   if (i<100) then
  25.     write(name,'(A,I2,A)') 'SSA_',i,'.data'
  26.     else
  27.     write(name,'(A,I3,A)') 'SSA_',i,'.data'
  28.   end if
  29.   open(unit = 10, File=name,status='unknown', &
  30.         form='unformatted',access = 'direct', recl=4*NX*NY)
  31.   open(unit = 11, File='NOaerosol_allsky.data',status='unknown', &
  32.         form='unformatted',access = 'direct', recl=4*NX*NY)
  33.   SUMM(:,:)=0.0
  34.   do k=0,11
  35.   read (10,rec=2+NV*k) OTOA !for any month
  36.   read (11,rec=1+3*k) TOA
  37.   ! print*, TOA(4,5)
  38.   DIFF=TOA-OTOA
  39.   ! print*, DIFF(8,9)
  40.   SUMM=SUMM+DIFF
  41.   end do
  42.   TIME_AVG=SUMM/12.
  43. ! print*, TIME_AVG(20,5)
  44. !____________________________________________________________________________________!
  45. !===========The mean variable at each LATitude for the selected month================!
  46. SUMLON=0.0
  47. do k=1,NY
  48.   do j=1,NX    
  49.       SUMLON(k)=SUMLON(k)+TIME_AVG(j,k)
  50.   enddo
  51. enddo
  52. LON_AVG=SUMLON/128.0
  53. !------------------------------------------------------------------------------------!
  54. ! using LATitude as an array
  55. LAT=(/-87.8638, -85.09653, -82.31291, -79.5256, -76.7369, -73.94752, &
  56. -71.15775, -68.36776, -65.57761, -62.78735, -59.99702, -57.20663, &
  57. -54.4162, -51.62573, -48.83524, -46.04473, -43.2542, -40.46365, &
  58. -37.67309, -34.88252, -32.09195, -29.30136, -26.51077, -23.72017, &
  59. -20.92957, -18.13897, -15.34836, -12.55776, -9.767145, -6.976533, &
  60. -4.185921, -1.395307, 1.395307, 4.185921, 6.976533, 9.767145, 12.55776, &
  61. 15.34836, 18.13897, 20.92957, 23.72017, 26.51077, 29.30136, 32.09195, &
  62. 34.88252, 37.67309, 40.46365, 43.2542, 46.04473, 48.83524, 51.62573, &
  63. 54.4162, 57.20663, 59.99702, 62.78735, 65.57761, 68.36776, 71.15775, &
  64. 73.94752, 76.7369, 79.5256, 82.31291, 85.09653, 87.8638/)
  65. ! =====================calcuLATing reLATive AREA for each grid ========================!
  66. do j=2,63
  67. AREA(j)=cos(LAT(j)*pi/180.)*(LAT(j+1)-LAT(j-1))/2.0
  68. enddo
  69. AREA(1)=cos(LAT(1)*pi/180.)*((LAT(1+1)+LAT(1))/2.0+90.0)
  70. AREA(NY)=cos(LAT(NY)*pi/180.)*(90.0-(LAT(NY-1)+LAT(NY))/2.0)
  71. !=========Taking cosine weighted mean ================================================!
  72. top=0.0; btm=0.0
  73. do j=1,64
  74.  top=top+AREA(j)*LON_AVG(j)
  75.  btm=btm+AREA(j)
  76. enddo
  77. !======================calcuLATe true AREA average===================================!
  78. true_avg=top/btm
  79. print*, true_avg
  80. close(10)
  81. close(11)
  82. enddo
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement