54 integer,
parameter :: MAX_VAR_DIMS = 10
59 integer (kind = integer_fourbyte) :: i,j,k,l,m,n
62 integer (kind = integer_fourbyte) :: hdfstatus
63 integer (kind = integer_fourbyte ), &
64 dimension(MAX_VAR_DIMS) :: hdfstart, hdfstride, hdfedge
65 integer (kind = integer_fourbyte) :: sds_id, sds_index
67 integer (kind = integer_fourbyte),
parameter :: numsnowalbstatwaves = 10
68 integer (kind = integer_fourbyte),
parameter :: numecosystems = 18
69 integer (kind = integer_fourbyte),
parameter :: numsnowtypes = 2
71 real :: snowalbedostats (1:numsnowalbstatwaves, 0:numecosystems-1, &
76 integer (kind = integer_fourbyte),
parameter :: numseaicealbwaves = 8
77 real (kind =
single),
dimension(NumSeaIceAlbWaves) :: meltseaicealbedos, &
79 real (kind =
single),
dimension(set_albedo_bands) :: &
80 processmeltseaicealbedos, processdryseaicealbedos, transitionalbedo, &
83 real (kind =
single),
parameter :: percentageofdry = 0.800d0
84 real :: wavelength(10)
91 character (len = *),
intent(in ) :: snowalbedofn
92 character (len = *),
dimension(:),
intent(in ) :: wavelengthtext
94 real (kind =
single),
dimension(NumSnowAlbStatWaves) :: possstatwavelengths
95 real (kind =
single),
dimension(NumSeaIceAlbWaves) :: possseaicewavelengths
97 integer :: errorlevel, i, numalbwavesprocess
106 numecosystems, snowalbedostats, errorlevel )
114 possstatwavelengths(1) = 0.470000
115 possstatwavelengths(2) = 0.555000
116 possstatwavelengths(3) = 0.659000
117 possstatwavelengths(4) = 0.858000
118 possstatwavelengths(5) = 1.240000
119 possstatwavelengths(6) = 1.640000
120 possstatwavelengths(7) = 2.130000
121 possstatwavelengths(8) = 0.0
122 possstatwavelengths(9) = 0.0
123 possstatwavelengths(10) = 0.0
130 do i = 1, numalbwavesprocess
131 read( wavelengthtext(i), * ) wavelength(i)
134 processsnowalbstats= 0.
135 do i = 1, numalbwavesprocess-1
138 do j = 1, numsnowalbstatwaves-3
139 if ( mod(wavelength(i),possstatwavelengths(j)) < 0.05 )
then
140 processsnowalbstats(i,:,:) = snowalbedostats(j,:,:)
146 if (.not. foundwave)
then
152 processsnowalbstats(6,:,:) = processsnowalbstats(5,:,:) * 0.5000
159 possseaicewavelengths(1) = 0.470000
160 possseaicewavelengths(2) = 0.555000
161 possseaicewavelengths(3) = 0.659000
162 possseaicewavelengths(4) = 0.858000
163 possseaicewavelengths(5) = 1.240000
164 possseaicewavelengths(6) = 1.640000
165 possseaicewavelengths(7) = 2.130000
166 possseaicewavelengths(8) = 3.700000
170 dryseaicealbedos(1:7) = snowalbedostats(1:7,15,1)
171 meltseaicealbedos(1:7) = snowalbedostats(1:7,15,1) * percentageofdry
173 dryseaicealbedos(8) = dryseaicealbedos(7) * 0.5000d0
174 meltseaicealbedos(8) = meltseaicealbedos(7) * 0.5000d0
179 do i = 1, numalbwavesprocess
181 do j = 1, numseaicealbwaves
182 if ( mod(wavelength(i),possseaicewavelengths(j)) < 0.05 )
then
183 processdryseaicealbedos(i) = dryseaicealbedos(j)
184 processmeltseaicealbedos(i) = meltseaicealbedos(j)
190 if (.not. foundwave)
then
200 subroutine getalbedoeco (Lat, Long, JulianDay, EcosystemFN, &
201 emissivity_name, Debug, WavelengthText, ProcessLandAlbedo, &
202 icec, Albedo, emissivity, Ecosystem, Status, sfc_info )
266 real (kind =
single ),
dimension(:,:),
intent(in ) :: lat, long
267 character (len = *),
intent(in ) :: ecosystemfn
268 character (len = *),
intent(in ) :: emissivity_name
269 integer (kind = integer_fourbyte ),
intent(in ) :: julianday
270 logical,
intent(in ) :: debug
271 character (len = *),
dimension(:),
intent(in ) :: wavelengthtext
272 logical,
dimension(:),
intent(in ) :: processlandalbedo
273 real (kind =
single),
dimension(:,:),
intent(in ) :: icec
274 real (kind =
single ),
dimension(:,:,:),
intent(out) :: emissivity
275 integer*2,
dimension(:,:,:),
intent(out) :: albedo
276 integer*1,
dimension(:,:),
intent(out) :: ecosystem, sfc_info
277 integer (kind = integer_fourbyte),
intent(out) :: status
369 integer (kind = integer_fourbyte) :: numalbwavesprocess
371 integer (kind = integer_fourbyte) :: numberofcols, numberofrows
376 real (kind =
single) :: minlat, maxlat, minlong, maxlong
382 integer (kind = integer_fourbyte) :: nummapcols, nummaprows
383 integer (kind = integer_fourbyte) :: nummapcols_alb, nummaprows_alb
386 real (kind =
single) :: map_resolution
387 real (kind =
single) :: map_resolution_alb
390 real (kind =
single) :: westernmostlongitude, northernmostlatitude
391 real (kind =
single) :: westernmostlongitude_alb, northernmostlatitude_alb
394 integer (kind = integer_fourbyte) :: startx, stopx, starty, stopy, &
395 numberofxpoints, numberofypoints
396 integer (kind = integer_fourbyte) :: startx_alb, stopx_alb, &
397 starty_alb, stopy_alb
398 real (kind =
single) :: startxval, stopxval, startyval, stopyval
401 real (kind =
single ),
parameter :: scalefactor = 0.00100
403 INTEGER(integer_fourbyte),
allocatable,
DIMENSION(:,:) :: snowicetype
406 integer (kind = integer_onebyte),
allocatable,
dimension(:,:) :: ecosystemmap
408 integer (kind = integer_fourbyte) :: xindex, yindex
409 integer (kind = integer_fourbyte) :: xindex_alb, yindex_alb
412 integer (kind = integer_fourbyte) :: ecomapfid, albmapfid
414 integer (kind = integer_fourbyte) :: ecomapsdsid, albmapsdsid
416 character(len = MAX_SDS_NAME_LEN) :: sdsname
419 INTEGER(integer_fourbyte) :: errorlevel
423 LOGICAL :: arcticmeltingseason, wintertomelttransition, melttowintertransition
424 integer (kind = integer_fourbyte),
parameter :: transitiondays = 10, &
425 nhmeltbeg = 152, nhmeltend = 244, shmeltbeg = 334, shmeltend = 61
428 real (kind =
single),
parameter :: wateralbedo = 0.050000
429 real,
dimension(:),
allocatable :: albedo_real4
430 real,
parameter :: emissivity_fill = 0.985
433 real,
parameter :: emissivity_res = 0.05
434 integer,
parameter :: num_emiss_cols = 7200
435 integer,
parameter :: num_emiss_rows = 3600
436 real,
dimension(:,:,:),
allocatable :: emissivity_map
437 integer*2,
dimension(:,:),
allocatable :: emissivity_map_int
438 integer :: emiss_x, emiss_y
439 real :: emiss_west, emiss_north
441 integer :: file_id, var_id, err_code, start(2), stride(2), edge(2)
458 integer :: dfacc_read = 1
463 real,
dimension(2) :: min_geo_sav = (/ -9000., -9000. /), &
464 max_geo_sav = (/ -9000., -9000. /)
465 real :: geo_margin = 5.
471 numberofcols =
size( albedo(:,:,:), dim = 1 )
472 numberofrows =
size( albedo(:,:,:), dim = 2 )
473 numalbwavesprocess =
size( albedo(:,:,:), dim = 3 )
475 if( .not.
allocated( albedo_real4) ) &
476 allocate(albedo_real4(numalbwavesprocess))
480 if ( (numberofcols < 1) .or. &
481 (numberofrows < 1) .or. &
482 (numalbwavesprocess < 2) .or. &
483 (numecosystems < 1) )
then
486 'Problem with albedo array size, contact SDST',status,
'getAlbedoEco')
496 if (maxval(lat) == -999. .or. maxval(long) == -999.)
then
498 albedo(:,:,:) = -999.
499 emissivity(:,:,:) = -999.
502 minlat = minval( lat, &
503 mask = ( (lat >= -90.0000 .and. lat <= 90.00000) ) )
504 maxlat = maxval( lat, &
505 mask = ( (lat >= -90.0000 .and. lat <= 90.00000) ) )
506 minlong = minval( long, &
507 mask = ( (long >= -180.000 .and. long <= 180.0000) ) )
508 maxlong = maxval( long, &
509 mask = ( (long >= -180.000 .and. long <= 180.0000) ) )
514 if( ( minlat < min_geo_sav(1) ) .or. ( maxlat > max_geo_sav(1) ) .or. &
515 ( minlong < min_geo_sav(2) ) .or. ( maxlong > max_geo_sav(2) ) )
then
521 minlat = minlat - geo_margin
522 maxlat = maxlat + geo_margin
523 minlong = minlong - geo_margin
524 maxlong = maxlong + geo_margin
526 if( minlat < -90. ) minlat = -90.
527 if( maxlat > 90. ) maxlat = 90.
528 if( minlong < -180. ) minlong = -180.
529 if( maxlong > 180. ) maxlong = 180.
531 min_geo_sav(1) = minlat
532 min_geo_sav(2) = minlong
533 max_geo_sav(1) = maxlat
534 max_geo_sav(2) = maxlong
555 map_resolution = 360.000d0 / float(nummapcols)
558 westernmostlongitude = map_resolution / 2.0 - 180.0
559 northernmostlatitude = 90.0 - map_resolution / 2.0
570 startx = anint( (minlong-westernmostlongitude) / (map_resolution) ) + 1
571 stopx = anint( (maxlong-westernmostlongitude) / (map_resolution) ) + 1
572 starty = anint( (northernmostlatitude-maxlat ) / (map_resolution) ) + 1
573 stopy = anint( (northernmostlatitude-minlat ) / (map_resolution) ) + 1
577 if (startx == 0) startx = 1
578 if (stopx == nummapcols+1 ) stopx = nummapcols
579 if (starty == 0) starty = 1
580 if (stopy == nummaprows+1 ) stopy = nummaprows
583 numberofxpoints = stopx - startx + 1
584 numberofypoints = stopy - starty + 1
587 if ( (startx < 1) .or. (stopx > nummapcols) .or. &
588 (starty < 1) .or. (stopy > nummaprows) .or. &
589 (startx > stopx) .or. (starty > stopy) )
then
594 if (stopx > nummapcols) stopx = nummapcols
595 if (stopy > nummaprows) stopy = nummaprows
596 if (startx > stopx) startx = stopx-1
597 if (starty > stopy) starty = stopy-1
598 if (startx < 1) startx = 1
599 if (starty < 1) starty = 1
613 if(
allocated(ecosystemmap) )
deallocate( ecosystemmap )
614 allocate( ecosystemmap(startx:stopx, starty:stopy ) )
622 hdfstart(1) = startx - 1
623 hdfstart(2) = starty - 1
630 hdfedge(1) = numberofxpoints
631 hdfedge(2) = numberofypoints
637 sdsname =
"IGBP_Land_Cover_Type"
640 ecomapfid = c_sfstart(
trim(ecosystemfn), dfacc_read)
641 if (ecomapfid == fail)
then
644 status,
'getAlbedoEco')
649 ecomapsdsid = c_sfselect(ecomapfid, c_sfn2index(ecomapfid,
trim(sdsname)))
650 if (ecomapsdsid == fail)
then
653 status,
'getAlbedoEco')
658 hdfstatus = c_sfrdata(ecomapsdsid, hdfstart, hdfstride, hdfedge, &
661 if (hdfstatus == fail)
then
664 status,
'getAlbedoEco')
669 hdfstatus = c_sfendacc( ecomapsdsid )
670 if (hdfstatus == fail)
then
673 status,
'getAlbedoEco')
676 hdfstatus = c_sfend( ecomapfid )
677 if (hdfstatus == fail)
then
680 status,
'getAlbedoEco')
688 emiss_west = emissivity_res / 2.0 - 180.0
689 emiss_north = 90.0 - emissivity_res / 2.0
693 startx = anint( (minlong-emiss_west) / (emissivity_res) ) + 1
694 stopx = anint( (maxlong-emiss_west) / (emissivity_res) ) + 1
695 starty = anint( (emiss_north-maxlat ) / (emissivity_res) ) + 1
696 stopy = anint( (emiss_north-minlat ) / (emissivity_res) ) + 1
700 if (startx == 0) startx = 1
701 if (stopx == num_emiss_cols+1 ) stopx = num_emiss_cols
702 if (starty == 0) starty = 1
703 if (stopy == num_emiss_rows+1 ) stopy = num_emiss_rows
706 numberofxpoints = stopx - startx + 1
707 numberofypoints = stopy - starty + 1
710 if ( (startx < 1) .or. (stopx > num_emiss_cols) .or. &
711 (starty < 1) .or. (stopy > num_emiss_rows) .or. &
712 (startx > stopx) .or. (starty > stopy) )
then
714 if (stopx > nummapcols) stopx = nummapcols
715 if (stopy > nummaprows) stopy = nummaprows
716 if (startx > stopx) startx = stopx-1
717 if (starty > stopy) starty = stopy-1
718 if (startx < 1) startx = 1
719 if (starty < 1) starty = 1
729 hdfstart(1) = startx - 1
730 hdfstart(2) = starty - 1
737 hdfedge(1) = numberofxpoints
738 hdfedge(2) = numberofypoints
741 if(
allocated( emissivity_map ) )
then
742 deallocate( emissivity_map )
744 allocate( emissivity_map(startx:stopx, starty:stopy, 2) )
745 allocate( emissivity_map_int(startx:stopx, starty:stopy ) )
747 ecomapfid = c_sfstart(
trim(emissivity_name), dfacc_read)
751 if (i==1) sdsname =
"emiss7"
752 if (i==2) sdsname =
"emiss14"
754 ecomapsdsid = c_sfselect(ecomapfid, c_sfn2index(ecomapfid, &
757 hdfstatus = c_sfrdata(ecomapsdsid, hdfstart, hdfstride, hdfedge, &
759 emissivity_map(:,:,i) = emissivity_map_int * scalefactor
761 hdfstatus = c_sfendacc(ecomapsdsid)
765 hdfstatus = c_sfend(ecomapfid)
767 deallocate(emissivity_map_int)
775 allocate( snowicetype(1:numberofcols, 1:numberofrows ) )
778 if (errorlevel == fail)
then
781 status,
'getAlbedoEco')
795 do i = 1, numberofcols
796 do j = 1, numberofrows
800 if ( (lat(i,j) >= -90.0000) .and. &
801 (lat(i,j) <= 90.0000) .and. &
802 (long(i,j) >= -180.000) .and. &
803 (long(i,j) <= 180.000) )
then
806 emiss_x = anint( (long(i,j)-emiss_west) / (emissivity_res) ) + 1
807 emiss_y = anint( (emiss_north-lat(i,j)) / (emissivity_res) ) + 1
809 if (emiss_x == 0) emiss_x = 1
810 if (emiss_x == num_emiss_cols+1 ) emiss_x = num_emiss_cols
811 if (emiss_y == 0) emiss_y = 1
812 if (emiss_y == num_emiss_rows+1 ) emiss_y = num_emiss_rows
815 emissivity(i,j, 1) = emissivity_map(emiss_x, emiss_y, 1)
816 emissivity(i,j, 2) = emissivity_map(emiss_x, emiss_y, 2)
818 if (emissivity(i,j,1) < 0.) emissivity(i,j,1) = emissivity_fill
819 if (emissivity(i,j,2) < 0.) emissivity(i,j,2) = emissivity_fill
829 xindex = anint( (long(i,j)-westernmostlongitude) / (map_resolution) ) + 1
830 yindex = anint( (northernmostlatitude-lat(i,j)) / (map_resolution) ) + 1
834 if (xindex == 0) xindex = 1
835 if (xindex == nummapcols+1 ) xindex = nummapcols
836 if (yindex == 0) yindex = 1
837 if (yindex == nummaprows+1 ) yindex = nummaprows
841 if ( (xindex < 1) .or. (xindex > nummapcols) &
842 .or. (yindex < 1) .or. (yindex > nummaprows) )
then
845 'Problem detected, bad array indexes (main loop) ',status,
'getAlbedoEco')
854 if (lat(i,j) >= 40.0 .or. lat(i,j) <= -40.0)
then
855 if (ecosystemmap(xindex,yindex) == 0)
then
859 if ( (icec(i,j) > 0.5 .and. icec(i,j) <= 1.0) &
860 .or. (snowicetype(i,j) == 101) &
861 .or. (snowicetype(i,j) == 200) )
then
864 snowicetype(i,j) = 95
867 if ( (snowicetype(i,j) >= 1 .and. snowicetype(i,j) <= 100) &
868 .or. (snowicetype(i,j) == 200) )
then
870 snowicetype(i,j) = 103
875 if (ecosystemmap(xindex,yindex) == 0)
then
876 if ( snowicetype(i,j) >= 30 .and. snowicetype(i,j) <= 100)
then
877 snowicetype(i,j) = snowicetype(i,j)
882 if ( icec(i,j) > 0. .and. icec(i,j) <= 1.0 ) &
883 snowicetype(i,j) = nint(icec(i,j)*100)
885 if ( icec(i,j) > 0.5 .and. icec(i,j) <= 1.0 ) &
886 snowicetype(i,j) = nint(icec(i,j)*100)
893 ecosystem(i,j) = ecosystemmap(xindex,yindex)
900 if ( (snowicetype(i,j) >= 1) &
901 .and. (snowicetype(i,j) <= 100) &
902 .and. (ecosystem(i,j) == 0) )
then
911 if (lat(i,j) >= 0.0)
then
913 SELECT CASE (julianday)
914 CASE ( (nhmeltbeg-transitiondays):nhmeltbeg-1)
918 slope(:) = (processmeltseaicealbedos(:) - &
919 processdryseaicealbedos(:)) /
real(transitiondays)
920 intercept(:) = processdryseaicealbedos(:) - slope(:) &
921 *
real(nhmeltbeg-transitiondays)
922 transitionalbedo(:) = slope(:) *
real(julianday) + intercept(:)
923 albedo_real4(:) = (transitionalbedo(:) * &
924 real(snowicetype(i,j))/100.000) &
925 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
926 CASE ( nhmeltbeg:nhmeltend )
928 albedo_real4(:) = (processmeltseaicealbedos(:) * &
929 real(snowicetype(i,j))/100.000) &
930 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
931 CASE ( nhmeltend+1:(nhmeltend+transitiondays) )
935 slope(:) = (processdryseaicealbedos(:)- &
936 processmeltseaicealbedos(:)) /
real(transitiondays)
937 intercept(:) = processmeltseaicealbedos(:) - slope(:) &
939 transitionalbedo(:) = slope(:) *
real(julianday) + intercept(:)
940 albedo_real4(:) = (transitionalbedo(:) * &
941 real(snowicetype(i,j))/100.000) &
942 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
945 albedo_real4(:) = (processdryseaicealbedos(:) * &
946 real(snowicetype(i,j))/100.000) &
947 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
954 SELECT CASE (julianday)
955 CASE ( (shmeltbeg-transitiondays):shmeltbeg-1)
959 slope(:) = (processmeltseaicealbedos(:)- &
960 processdryseaicealbedos(:)) &
961 /
real(transitiondays)
962 intercept(:) = processdryseaicealbedos(:) - slope(:) &
963 *
real(shmeltbeg-transitiondays)
964 transitionalbedo(:) = slope(:) *
real(julianday) + intercept(:)
965 albedo_real4(:) = (transitionalbedo(:) * &
966 real(snowicetype(i,j))/100.000) &
967 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
969 CASE ( shmeltbeg:366 )
971 albedo_real4(:) = (processmeltseaicealbedos(:) * &
972 real(snowicetype(i,j))/100.000) &
973 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
976 albedo_real4(:) = (processmeltseaicealbedos(:) * &
977 real(snowicetype(i,j))/100.000) &
978 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
979 CASE (shmeltend+1:(shmeltend+transitiondays) )
983 slope(:) = (processdryseaicealbedos(:)- &
984 processmeltseaicealbedos(:)) /
real(transitiondays)
985 intercept(:) = processmeltseaicealbedos(:) - slope(:) * &
988 transitionalbedo(:) = slope(:) *
real(julianday) + intercept(:)
989 albedo_real4(:) = (transitionalbedo(:) * &
990 real(snowicetype(i,j))/100.000) &
991 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
995 albedo_real4(:) = (processdryseaicealbedos(:) * &
996 real(snowicetype(i,j))/100.000) &
997 + (wateralbedo *
real(100-snowicetype(i,j))/100.000)
1002 albedo(i,j,:) = nint(albedo_real4(:)*1000.)
1004 else if ( ecosystem(i,j) == 15 .or. snowicetype(i,j) == 101 )
then
1007 if ((ecosystem(i,j) == 15) .and. &
1013 albedo(i,j,:) = nint( (1.0 - emissivity(i,j,1))*1000.)
1021 albedo(i,j,:) = nint(processsnowalbstats(:, ecosystem(i,j), 1)*1000.)
1022 albedo(i,j,6) = nint( (1.0 - emissivity(i,j,1))*1000.)
1027 else if ( snowicetype(i,j) == 103 )
then
1030 albedo(i,j,:) = nint( processsnowalbstats(:, ecosystem(i,j), 1) * 1000.)
1031 albedo(i,j,6) = nint( (1.0 - emissivity(i,j,1))*1000.)
1038 else if (snowicetype(i,j) >= 30 .and. snowicetype(i,j) <= 100 .and. &
1039 ecosystem(i,j) /= 0)
then
1041 (1.-snowicetype(i,j)*0.01) + &
1042 snowicetype(i,j)*0.01* &
1043 processsnowalbstats(:, ecosystem(i,j), 1)) * 1000.)
1044 albedo(i,j,6) = nint( (1.0 - emissivity(i,j,1))*1000.)
1051 else if ( snowicetype(i,j) == 104 )
then
1054 albedo(i,j,:) = nint(processsnowalbstats(:, ecosystem(i,j), 2) * 1000.)
1055 albedo(i,j,6) = nint((1.0 - emissivity(i,j,1))*1000.)
1061 else if (ecosystem(i,j) == 0)
then
1063 albedo(i,j,:) = nint(wateralbedo*1000.)
1072 albedo(i,j,6) = nint((1.0 - emissivity(i,j,1))*1000.)
1080 albedo(i,j,:) = -999
1081 emissivity(i,j,:) = -999.
1093 deallocate( snowicetype )
1096 if (status > 0 )
then
1099 status,
'getAlbedoEco')