From ee6283aa5034c3aabdc74809aba186bd04d2bb05 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Wed, 3 Aug 2022 09:11:43 -0400 Subject: [PATCH 01/77] add snow albedo to catch_params.nc4 --- .../Utils/Raster/make_bcs | 2 + .../Utils/Raster/mkCatchParam.F90 | 39 ++- .../Utils/Raster/mod_process_hres_data.F90 | 251 ++++++++++++++++++ .../Utils/Raster/rmTinyCatchParaMod.F90 | 9 + 4 files changed, 300 insertions(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index a174aff89..2d7935fa9 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -105,6 +105,7 @@ echo " ${C2}ICA : Icarus (/discover/nobackup/ltakacs/bcs/Icarus/)" echo " ${C2}NL3 : Icarus-NLv3 (/discover/nobackup/ltakacs/bcs/Icarus-NLv3/)" echo " ${C2}NL4 : NLv4 [SMAP] (/discover/nobackup/projects/gmao/smap/bcs_NLv4/NLv4/)" echo " ${C2}NL5 : NLv5 [SMAP]" +echo " ${C2}NL6 : NLv6 [SMAP with snow albedo from MODIS]" echo " ${C2}DEV : Development version${CR}" echo " " if ( $HELPMODE != YES ) then @@ -132,6 +133,7 @@ if ( $HELPMODE != YES ) then $dummy == 'NL3' | \ $dummy == 'NL4' | \ $dummy == 'NL5' | \ + $dummy == 'NL6' | \ $dummy == 'DEV') then set lbcsv = $dummy else if ( $dummy == '' ) then diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index fe035a9e5..f6f26e7b0 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -564,7 +564,7 @@ PROGRAM mkCatchParam if( F25Tag) call soil_para_high (nc,nr,regrid,gridnamer,F25Tag=F25Tag) if(.not.F25Tag) call soil_para_high (nc,nr,regrid,gridnamer) endif - if(SOILBCS=='HWSD') call soil_para_hwsd (nc,nr,gridnamer) + if(SOILBCS=='HWSD') call soil_para_hwsd (nc,nr,gridnamer) write (log_file,'(a)')' Done.' else write (log_file,'(a,a)')' Using existing file.' @@ -653,6 +653,43 @@ PROGRAM mkCatchParam endif write (log_file,'(a)')' ' + ! Biljana + ! Creating snow_alb_param.dat + ! --------------------------------------------------------------------- + if(use_snow_albedo)then + tmpstring = 'Step 14: Snow albedo from MODIS' + ! here I should test if snow_alb is written into nc file + ! and call the soil_snow_alb subroutine only if it's not there + ! inquire(file='clsm/catch_params.nc4', exist=file_exists) + ! if (.not.file_exists) then + ! write (log_file,'(a)')' clsm/catch_params.nc4 is missing. Something is wrong. STOP!' + ! stop + ! else + ! inquire for snow albedo variable + + ! if not present, inititate + write (log_file,'(a)')' Loading snow albedo...' + call soil_snow_alb (nc,nr,gridnamer) + write (log_file,'(a)')' Done.' + + ! if present and loaded, do nothing + + ! endif + + !fname_tmp = 'clsm/snow_alb_param.dat' + !write (log_file,'(a,a,a,a)') trim(tmpstring), ' (', trim(fname_tmp), ')' + !inquire(file=trim(fname_tmp), exist=file_exists) + !if (.not.file_exists) then + ! write (log_file,'(a)')' Creating file...' + ! call soil_snow_alb (nc,nr,gridnamer) + ! write (log_file,'(a)')' Done.' + !else + ! write (log_file,'(a,a)')' Using existing file.' + !endif + write (log_file,'(a)')' ' + endif ! if use_snow_albedo + ! Biljana -- done creating snow albedo file + ! inquire(file='clsm/irrig.dat', exist=file_exists) ! if (.not.file_exists) call create_irrig_params (nc,nr,gridnamer) ! write (log_file,'(a)')'Done computing irrigation model parameters ...............13' diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index a75036635..de11d794e 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -26,6 +26,7 @@ MODULE process_hres_data use leap_year use MAPL_ConstantsMod use lsm_routines, ONLY: sibalb +USE IFPORT ! Biljana #if defined USE_EXTERNAL_FINDLOC use findloc_mod, only: findloc @@ -38,6 +39,7 @@ MODULE process_hres_data private public :: soil_para_hwsd,hres_lai,hres_gswp2, merge_lai_data, grid2tile_modis6 +public :: soil_snow_alb ! Biljana public :: modis_alb_on_tiles_high,modis_scale_para_high,hres_lai_no_gswp public :: histogram, create_mapping, esa2mosaic , esa2clm public :: grid2tile_ndep_t2m_alb, CREATE_ROUT_PARA_FILE, map_country_codes, get_country_codes @@ -2986,6 +2988,254 @@ END SUBROUTINE hres_gswp2 !---------------------------------------------------------------------- + SUBROUTINE soil_snow_alb (nx,ny,gfiler) ! Biljana + +! Implement snow albedo calculated from MOIDS 22-year climatology. Store snow albedo +! values in clsm/catch_params.nc4 +! Biljana Orescanin July 2022, SSAI@NASA + + implicit none + integer, intent (in) :: nx, ny + character(*) :: gfiler + integer,allocatable,target,dimension (:,:) :: tile_id + + character*200 :: fname + character*2 :: vv,hh + integer :: n,maxcat,i,j,k,ncid,status + real,allocatable,dimension(:) :: min_lon,max_lon,min_lat,max_lat,snw_alb + integer(kind=4),parameter :: xdim = 1200, ydim = 1200 + real,parameter :: alb_res=10.0/1200.0 + real,dimension(xdim) :: lon_alb + real,dimension(ydim) :: lat_alb + real,dimension(xdim,ydim) :: stch_snw_alb_tmp + real,dimension(36,18,xdim,ydim) :: stch_snw_alb + real :: minlon,maxlon,minlat,maxlat,pad_lon,pad_lat + real :: sno_alb_cnt, sno_alb_sum,sno_alb_cnt2,sno_alb_sum2 + integer :: vvtil_min,hhtil_min,vvtil_max,hhtil_max,hhtil,vvtil + integer :: tindex1,pfaf1 + integer(kind=4) :: dummy,VarID,varid1,varid2,varid3 + integer(kind=4) :: imin,imax,jmin,jmax + integer(kind=4) :: imin2,imax2,jmin2,jmax2,count_init_invalid + logical :: file_exists + + ! Read number of catchment-tiles (maxcat) from catchment.def file + fname='clsm/catchment.def' + open (10,file=fname,status='old',action='read',form='formatted') + read(10,*) maxcat + + ! read min/max lat/lons, so those can be used to locate + ! snow albedo grids in the stitched MODIS albedo file + allocate (min_lon(1:maxcat)) + allocate (min_lat(1:maxcat)) + allocate (max_lon(1:maxcat)) + allocate (max_lat(1:maxcat)) + allocate (snw_alb(1:maxcat)) + + ! before populating, set all snow albedo values to missing + snw_alb(:)=-9999.0 + + do n = 1, maxcat + read (10,*) tindex1,pfaf1,minlon,maxlon,minlat,maxlat + min_lon(n) = minlon + max_lon(n) = maxlon + min_lat(n) = minlat + max_lat(n) = maxlat + end do + + close (10,status='keep') + + ! Read tile-id raster file + allocate(tile_id(1:nx,1:ny)) + + fname=trim(gfiler)//'.rst' + open (10,file=fname,status='old',action='read', & + form='unformatted',convert='little_endian') + + do j=1,ny + read(10)tile_id(:,j) + end do + + close (10,status='keep') + + !------------ Get the information on snow albedo ----- + ! ----------- The information on snow albedo is stored in 10x10 30-arcsec files. Read in this + ! information. Then loop over tiles to find a corresponding snow albedo mean + + ! read in all 10x10deg snow albedo files into a single [36,18,1200,1200] array + do hhtil=1,36 ! loop over all horziontal input files + do vvtil=1,18 ! loop over all vertical input files + + write(vv,'(i2.2)') vvtil + write(hh,'(i2.2)') hhtil + + fname = '/discover/nobackup/borescan/tools/idl/01_snow_fraction/06_modis_nsidc/'// & + '/data/data_out/snow_alb_all_08_Top99th_percentile_MOD10A1.A_30arcsec_'// & + '2000_2022_H'//hh//'V'//vv//'.nc' + + ! Open the file. NF90_NOWRITE tells netCDF we want read-only access to the file. + status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) + ! Get the varid of the data variable, based on its name. + status=NF_INQ_VARID(ncid,'Snow_Albedo',VarID1) ; VERIFY_(STATUS) + status=NF_INQ_VARID(ncid,'lon' ,VarID2) ; VERIFY_(STATUS) + status=NF_INQ_VARID(ncid,'lat' ,VarID3) ; VERIFY_(STATUS) + ! Read the data. + status=NF_GET_VARA_REAL(ncid,VarID1,(/1,1/),(/xdim,ydim/),stch_snw_alb_tmp) ; VERIFY_(STATUS) + status=NF_GET_VARA_REAL(ncid,VarID2,(/1/) ,(/xdim/) ,lon_alb) ; VERIFY_(STATUS) + status=NF_GET_VARA_REAL(ncid,VarID3,(/1/) ,(/ydim/) ,lat_alb) ; VERIFY_(STATUS) + ! Close the file, freeing all resources. + status=NF_CLOSE(ncid); VERIFY_(STATUS) + + ! store into large aray + stch_snw_alb(hhtil,vvtil,:,:)=stch_snw_alb_tmp + + enddo + enddo + + ! open the file to write snow albedo output in +! fname ='clsm/snow_alb_param.dat' +! open(11,file=trim(fname),form='formatted',status='unknown',action = 'write') + + ! loop over tiles + print*, 'Starting tile loop for snow albedo. Biljana' + count_init_invalid=0 ! counter for non-valid snow albedo after matching tile size + + do n = 1, maxcat ! loop over tile + + ! set the current tile snow albedo to missing. Then start calculations to see if not missing. + snw_alb(n)=-9999.0 + + ! set sums and counts to zero + sno_alb_sum=0. + sno_alb_cnt=0. + sno_alb_sum2=0. + sno_alb_cnt2=0. + + ! This tile has min/max lat/lon info. Use this info to identify which 10x10deg + ! snow albedo file(s) to read in (and then loop over these files). + ! Using ceiling and floor for max and min range, the "halo" approach is + ! implemented. + vvtil_min= floor((min_lat(n)+ 90.0)/10.) + hhtil_min= floor((min_lon(n)+180.0)/10.) + vvtil_max=ceiling((max_lat(n)+ 90.0)/10.) + hhtil_max=ceiling((max_lon(n)+180.0)/10.) + + ! make sure vv's and hh's are within the range + ! if min>max, swap them + if (vvtil_min .gt. vvtil_max) then + dummy =vvtil_min + vvtil_min=vvtil_max + vvtil_max=dummy + endif + if (hhtil_min .gt. hhtil_max) then + dummy =hhtil_min + hhtil_min=hhtil_max + hhtil_max=dummy + endif + + ! if beyond the range, bring them back + vvtil_min=max(vvtil_min,1) + vvtil_max=min(vvtil_max,18) + hhtil_min=max(hhtil_min,1) + hhtil_max=min(hhtil_max,36) + + do hhtil=hhtil_min,hhtil_max ! loop over all horziontal input files + do vvtil=vvtil_min,vvtil_max ! loop over all vertical input files + + ! find indices covered by the tile + imin=floor((min_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) + imax=floor((max_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) + jmin=floor((min_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) + jmax=floor((max_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) + ! make sure to stay within the range + imin=max(imin,1) + imax=min(imax,xdim) + jmin=max(jmin,1) + jmax=min(jmax,ydim) + + ! sum snow albedo values and counts for current tile corresponding indices + sno_alb_sum= sno_alb_sum + & + sum(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax), & + stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & + stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax).le.1.0) + + sno_alb_cnt= sno_alb_cnt + & + count(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & + stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax).le.1.0) + + end do ! vvtil + end do ! hhtil + ! get mean snow albedo over the tile + snw_alb(n) = sno_alb_sum / max(1.0,sno_alb_cnt) + if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=-9999.0 !1.E15 + + ! if no valid solition, and if tile size is smaller than the snow albedo grid box, + ! then expand the search areaby 1 tile in each direction + + ! size of a tile (in both directions) + pad_lon=(max_lon(n)-min_lon(n)) + pad_lat=(max_lat(n)-min_lat(n)) + + if (snw_alb(n) .le. 0.0 .and. (pad_lon .lt. alb_res .or. pad_lat .lt. alb_res)) then + + count_init_invalid=count_init_invalid+1 + + do hhtil=hhtil_min,hhtil_max ! loop over all horziontal input files + do vvtil=vvtil_min,vvtil_max ! loop over all vertical input files + + ! find indices of snow albedo array corresponding to the current tile + imin2=floor((min_lon(n)-pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) + imax2=floor((max_lon(n)+pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) + jmin2=floor((min_lat(n)-pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) + jmax2=floor((max_lat(n)+pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) + imin2=max(imin2,1) + imax2=min(imax2,xdim) + jmin2=max(jmin2,1) + jmax2=min(jmax2,ydim) + + ! sum snow albedo values and counts for current tile corresponding indices + sno_alb_sum2= sno_alb_sum2 + & + sum(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2), & + stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & + stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2).le.1.0) + + sno_alb_cnt2= sno_alb_cnt2 + & + count(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & + stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2).le.1.0) + + end do ! vvtil + end do ! hhtil + + snw_alb(n) = sno_alb_sum2 / max(1.0,sno_alb_cnt2) + if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=-9999.0 !1.E15 + + endif + + ! write the current tile value into the filr +! write (11,'(i10,i8,f13.4)') tindex1,pfaf1,snw_alb(n) + + end do ! n-loop over tiles + + ! write snow albedo into clsm/catch_params.nc4 + inquire(file='clsm/catch_params.nc4', exist=file_exists) + + if(file_exists) then + status = NF_OPEN ('clsm/catch_params.nc4', NF_WRITE, ncid ) ; VERIFY_(STATUS) + status = NF_PUT_VARA_REAL(NCID,NC_VarID(NCID,'SNOWALB'),(/1/),(/maxcat/),real(snw_alb)) ; VERIFY_(STATUS) + STATUS = NF_CLOSE (NCID) ; VERIFY_(STATUS) + endif + +! ! close the output file +! write (11,'(a)')' ' +! write (11,'(a)')'TileIndex PfafID snw_alb' +! close (11, status = 'keep') + + print*, 'Ended tile loop for snow albedo. Biljana' + print*, 'There has been ',count_init_invalid,' inital non-valid snow values (out of',maxcat,')' + + END SUBROUTINE soil_snow_alb ! Biljana + + !-------------------------------------------------------------------------------------- + SUBROUTINE soil_para_hwsd (nx,ny,gfiler) ! Processing NGDC-HWSD-STATSGO merged soil properties with Woesten Soil @@ -5895,6 +6145,7 @@ SUBROUTINE open_landparam_nc4_files(N_tile) call DEF_VAR ( NCCatOUTID, CellID1,'TSB2' ,'water_transfer_param_4' ,'1' ) call DEF_VAR ( NCCatOUTID, CellID1,'WPWET' ,'wetness_at_wilting_point' ,'1' ) call DEF_VAR ( NCCatOUTID, CellID1,'DP2BR' ,'depth_to_bedrock' ,'mm' ) + call DEF_VAR ( NCCatOUTID, CellID1,'SNOWALB' ,'snow_albedo' ,'1' ) ! Biljana call DEF_VAR ( NCVegOUTID, CellID3,'ITY' ,'vegetation_type' ,'1' ) call DEF_VAR ( NCVegOUTID, CellID3,'Z2CH' ,'vegetation_height' ,'m' ) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index fd381b50c..43f6dee9c 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -45,6 +45,7 @@ module rmTinyCatchParaMod INTEGER, PARAMETER, public:: SRTM_maxcat = 291284 logical, public, save :: use_PEATMAP = .true. logical, public, save :: jpl_height = .true. + logical, public, save :: use_snow_albedo = .false. ! Biljana character*8, public, save :: LAIBCS = 'MODGEO' character*4, public, save :: SOILBCS = 'HWSD' character*6, public, save :: MODALB = 'MODIS2' @@ -117,6 +118,14 @@ SUBROUTINE init_bcs_config (LBSV) use_PEATMAP = .true. jpl_height = .true. + case ("NL6") !! Biljana New boundary condition option + LAIBCS = 'MODGEO' + SOILBCS = 'HWSD' + MODALB = 'MODIS2' + use_PEATMAP = .true. + jpl_height = .true. + use_snow_albedo= .true. + case ("DEV") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' From cb9ca6560cca12e3a303921e1fb8450f5879bbb1 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Mon, 8 Aug 2022 09:14:32 -0400 Subject: [PATCH 02/77] fix log message --- .../GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index f6f26e7b0..466c355d6 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -658,6 +658,7 @@ PROGRAM mkCatchParam ! --------------------------------------------------------------------- if(use_snow_albedo)then tmpstring = 'Step 14: Snow albedo from MODIS' + write (log_file,'(a)') trim(tmpstring) ! here I should test if snow_alb is written into nc file ! and call the soil_snow_alb subroutine only if it's not there ! inquire(file='clsm/catch_params.nc4', exist=file_exists) From 14f2eac0ad4367684cf3ef4eb27041d33bd35bfa Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Wed, 10 Aug 2022 20:46:01 -0400 Subject: [PATCH 03/77] edit comments, fix gnu error --- .../Utils/Raster/mkCatchParam.F90 | 27 ------------------- .../Utils/Raster/mod_process_hres_data.F90 | 19 +++++++------ .../Utils/Raster/rmTinyCatchParaMod.F90 | 4 +-- 3 files changed, 11 insertions(+), 39 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index 466c355d6..f8d22c2c7 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -653,43 +653,16 @@ PROGRAM mkCatchParam endif write (log_file,'(a)')' ' - ! Biljana ! Creating snow_alb_param.dat ! --------------------------------------------------------------------- if(use_snow_albedo)then tmpstring = 'Step 14: Snow albedo from MODIS' write (log_file,'(a)') trim(tmpstring) - ! here I should test if snow_alb is written into nc file - ! and call the soil_snow_alb subroutine only if it's not there - ! inquire(file='clsm/catch_params.nc4', exist=file_exists) - ! if (.not.file_exists) then - ! write (log_file,'(a)')' clsm/catch_params.nc4 is missing. Something is wrong. STOP!' - ! stop - ! else - ! inquire for snow albedo variable - - ! if not present, inititate write (log_file,'(a)')' Loading snow albedo...' call soil_snow_alb (nc,nr,gridnamer) write (log_file,'(a)')' Done.' - - ! if present and loaded, do nothing - - ! endif - - !fname_tmp = 'clsm/snow_alb_param.dat' - !write (log_file,'(a,a,a,a)') trim(tmpstring), ' (', trim(fname_tmp), ')' - !inquire(file=trim(fname_tmp), exist=file_exists) - !if (.not.file_exists) then - ! write (log_file,'(a)')' Creating file...' - ! call soil_snow_alb (nc,nr,gridnamer) - ! write (log_file,'(a)')' Done.' - !else - ! write (log_file,'(a,a)')' Using existing file.' - !endif write (log_file,'(a)')' ' endif ! if use_snow_albedo - ! Biljana -- done creating snow albedo file ! inquire(file='clsm/irrig.dat', exist=file_exists) ! if (.not.file_exists) call create_irrig_params (nc,nr,gridnamer) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index de11d794e..857607e07 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -26,7 +26,6 @@ MODULE process_hres_data use leap_year use MAPL_ConstantsMod use lsm_routines, ONLY: sibalb -USE IFPORT ! Biljana #if defined USE_EXTERNAL_FINDLOC use findloc_mod, only: findloc @@ -39,7 +38,7 @@ MODULE process_hres_data private public :: soil_para_hwsd,hres_lai,hres_gswp2, merge_lai_data, grid2tile_modis6 -public :: soil_snow_alb ! Biljana +public :: soil_snow_alb public :: modis_alb_on_tiles_high,modis_scale_para_high,hres_lai_no_gswp public :: histogram, create_mapping, esa2mosaic , esa2clm public :: grid2tile_ndep_t2m_alb, CREATE_ROUT_PARA_FILE, map_country_codes, get_country_codes @@ -2988,7 +2987,7 @@ END SUBROUTINE hres_gswp2 !---------------------------------------------------------------------- - SUBROUTINE soil_snow_alb (nx,ny,gfiler) ! Biljana + SUBROUTINE soil_snow_alb (nx,ny,gfiler) ! Implement snow albedo calculated from MOIDS 22-year climatology. Store snow albedo ! values in clsm/catch_params.nc4 @@ -3068,9 +3067,9 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) ! Biljana write(vv,'(i2.2)') vvtil write(hh,'(i2.2)') hhtil - fname = '/discover/nobackup/borescan/tools/idl/01_snow_fraction/06_modis_nsidc/'// & - '/data/data_out/snow_alb_all_08_Top99th_percentile_MOD10A1.A_30arcsec_'// & - '2000_2022_H'//hh//'V'//vv//'.nc' + fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/'// & + 'albedo/snow/MODIS/v1/snow_alb_MOD10A1.061_30arcsec_'// & + '2000_2022_H'//hh//'V'//vv//'.nc' ! Open the file. NF90_NOWRITE tells netCDF we want read-only access to the file. status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) @@ -3096,7 +3095,7 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) ! Biljana ! open(11,file=trim(fname),form='formatted',status='unknown',action = 'write') ! loop over tiles - print*, 'Starting tile loop for snow albedo. Biljana' + print*, 'Starting tile loop for snow albedo. ' count_init_invalid=0 ! counter for non-valid snow albedo after matching tile size do n = 1, maxcat ! loop over tile @@ -3229,10 +3228,10 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) ! Biljana ! write (11,'(a)')'TileIndex PfafID snw_alb' ! close (11, status = 'keep') - print*, 'Ended tile loop for snow albedo. Biljana' + print*, 'Ended tile loop for snow albedo. ' print*, 'There has been ',count_init_invalid,' inital non-valid snow values (out of',maxcat,')' - END SUBROUTINE soil_snow_alb ! Biljana + END SUBROUTINE soil_snow_alb !-------------------------------------------------------------------------------------- @@ -6145,7 +6144,7 @@ SUBROUTINE open_landparam_nc4_files(N_tile) call DEF_VAR ( NCCatOUTID, CellID1,'TSB2' ,'water_transfer_param_4' ,'1' ) call DEF_VAR ( NCCatOUTID, CellID1,'WPWET' ,'wetness_at_wilting_point' ,'1' ) call DEF_VAR ( NCCatOUTID, CellID1,'DP2BR' ,'depth_to_bedrock' ,'mm' ) - call DEF_VAR ( NCCatOUTID, CellID1,'SNOWALB' ,'snow_albedo' ,'1' ) ! Biljana + call DEF_VAR ( NCCatOUTID, CellID1,'SNOWALB' ,'snow_albedo' ,'1' ) call DEF_VAR ( NCVegOUTID, CellID3,'ITY' ,'vegetation_type' ,'1' ) call DEF_VAR ( NCVegOUTID, CellID3,'Z2CH' ,'vegetation_height' ,'m' ) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index 43f6dee9c..91ccd2459 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -45,7 +45,7 @@ module rmTinyCatchParaMod INTEGER, PARAMETER, public:: SRTM_maxcat = 291284 logical, public, save :: use_PEATMAP = .true. logical, public, save :: jpl_height = .true. - logical, public, save :: use_snow_albedo = .false. ! Biljana + logical, public, save :: use_snow_albedo = .false. character*8, public, save :: LAIBCS = 'MODGEO' character*4, public, save :: SOILBCS = 'HWSD' character*6, public, save :: MODALB = 'MODIS2' @@ -118,7 +118,7 @@ SUBROUTINE init_bcs_config (LBSV) use_PEATMAP = .true. jpl_height = .true. - case ("NL6") !! Biljana New boundary condition option + case ("NL6") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' From 0c092d05c212ee4cba5edc2916612718ddf78455 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Wed, 10 Aug 2022 20:50:56 -0400 Subject: [PATCH 04/77] edit --- .../Utils/Raster/mod_process_hres_data.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index 857607e07..577846f74 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -3068,8 +3068,8 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) write(hh,'(i2.2)') hhtil fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/'// & - 'albedo/snow/MODIS/v1/snow_alb_MOD10A1.061_30arcsec_'// & - '2000_2022_H'//hh//'V'//vv//'.nc' + '/albedo/snow/MODIS/v1/snow_alb_MOD10A1.061_30arcsec_'// & + '2000_2022_H'//hh//'V'//vv//'.nc' ! Open the file. NF90_NOWRITE tells netCDF we want read-only access to the file. status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) From 3039868d6ba45c9ab13b4611896a8bed8f9b601b Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Wed, 10 Aug 2022 20:56:21 -0400 Subject: [PATCH 05/77] edit#2 --- .../Utils/Raster/mod_process_hres_data.F90 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index 577846f74..0f31beed6 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -3067,9 +3067,7 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) write(vv,'(i2.2)') vvtil write(hh,'(i2.2)') hhtil - fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/'// & - '/albedo/snow/MODIS/v1/snow_alb_MOD10A1.061_30arcsec_'// & - '2000_2022_H'//hh//'V'//vv//'.nc' + fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v1/snow_alb_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' ! Open the file. NF90_NOWRITE tells netCDF we want read-only access to the file. status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) From 473a6323642ca07b2230ca5ffae5c03a131f52e4 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 11 Aug 2022 13:05:19 -0400 Subject: [PATCH 06/77] add SNOWALB to CatmentRst object --- .../Utils/mk_restarts/CatchmentRst.F90 | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index 0ea043b54..b2ece52ff 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -76,6 +76,7 @@ module CatchmentRstMod real, allocatable :: sndzn1(:) real, allocatable :: sndzn2(:) real, allocatable :: sndzn3(:) + real, allocatable :: snowalb(:) real, allocatable :: ch(:,:) real, allocatable :: cm(:,:) real, allocatable :: cq(:,:) @@ -427,6 +428,9 @@ subroutine write_shared_nc4(this, formatter, rc) if (this%meta%has_variable('WW')) then call MAPL_VarWrite(formatter,"WW",this%ww) endif + if (this%meta%has_variable('SNOWALB')) then + call MAPL_VarWrite(formatter,"SNOWALB",this%snowalb) + endif _RETURN(_SUCCESS) @@ -483,6 +487,9 @@ subroutine allocate_catch(this,rc) if (this%meta%has_variable('TSURF')) then allocate( this% tsurf(ntiles) ) endif + if (this%meta%has_variable('SNOWALB')) then + allocate( this% snowalb(ntiles) ) + endif allocate( this% wesnn1(ntiles) ) allocate( this% wesnn2(ntiles) ) @@ -509,6 +516,7 @@ subroutine allocate_catch(this,rc) if (this%meta%has_variable('WW')) then allocate( this% ww(ntiles,4) ) endif + _RETURN(_SUCCESS) end subroutine allocate_catch @@ -529,6 +537,8 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) logical :: file_exists type(NetCDF4_Fileformatter) :: CatchFmt + type(Variable) :: var + type(FileMetadata) :: meta_ character*256 :: Iam = "add_bcs" @@ -611,6 +621,18 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) call MAPL_VarRead ( CatchFmt ,'WPWET', this%WPWET, __RC__) call MAPL_VarRead ( CatchFmt ,'DP2BR', DP2BR, __RC__) call MAPL_VarRead ( CatchFmt ,'POROS', this%POROS, __RC__) + meta_ = CatchFmt%read(__RC__) + if ( meta_%has_variable('SNOWALB')) then + if ( .not. allocated(this%snowalb)) allocate(this%snowalb(ntiles)) + call MAPL_VarRead ( CatchFmt ,'SNOWALB', this%snowalb, __RC__) + if ( .not. this%meta%has_variable('SNOWALB')) then + var = Variable(type=pFIO_REAL32, dimensions='tile') + call var%add_attribute('long_name', 'snow_albedo') + call var%add_attribute('units', '1') + call this%meta%add_variable('SNOWALB', var) + endif + endif + call CatchFmt%close() else open(unit=21, file=trim(DataDir)//'/clsm/mosaic_veg_typs_fracs',form='formatted') @@ -1069,6 +1091,10 @@ subroutine re_tile(this, InTileFile, OutBcsDir, OutTileFile, surflay, rc) var_out = this%tsurf(id_glb(:)) this%tsurf = var_out endif + if (this%meta%has_variable('SNOWALB')) then + var_out = this%snowalb(id_glb(:)) + this%snowalb = var_out + endif ! CH CM CQ FR WW ! WW From 1e1faa551d0bfe732f61c9e4d0018e0bf12f578f Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Thu, 18 Aug 2022 19:39:22 -0400 Subject: [PATCH 07/77] use snowalb info + add to surface rc file --- .../GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 49 ++++++++++++++++++- .../Shared/GEOS_SurfaceGridComp.rc | 8 +++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index de12911f0..981c0eb33 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -896,6 +896,16 @@ subroutine SetServices ( GC, RC ) RC=STATUS ) VERIFY_(STATUS) + call MAPL_AddInternalSpec(GC ,& + LONG_NAME = 'snow_albedo' ,& + UNITS = '1' ,& + SHORT_NAME = 'SNOWALB' ,& + FRIENDLYTO = trim(COMP_NAME) ,& + DIMS = MAPL_DimsTileOnly ,& + VLOCATION = MAPL_VLocationNone ,& + RESTART = MAPL_RestartRequired ,& + RC=STATUS ) + VERIFY_(STATUS) call MAPL_AddInternalSpec(GC ,& LONG_NAME = 'wetness_at_wilting_point' ,& UNITS = '1' ,& @@ -3763,6 +3773,7 @@ subroutine Driver ( RC ) real, dimension(:), pointer :: psis real, dimension(:), pointer :: bee real, dimension(:), pointer :: poros + real, dimension(:), pointer :: snowalb real, dimension(:), pointer :: wpwet real, dimension(:), pointer :: cond real, dimension(:), pointer :: gnu @@ -4132,6 +4143,10 @@ subroutine Driver ( RC ) integer :: nv, nVars integer :: nDims,dimSizes(3) integer :: ldas_ens_id, ldas_first_ens_id + + integer :: SNOW_ALBEDO_INFO + character(len=ESMF_MAXSTR) :: SURFRC + type(ESMF_Config) :: SCF !#--- ! -------------------------------------------------------------------------- @@ -4354,8 +4369,8 @@ subroutine Driver ( RC ) call MAPL_GetPointer(INTERNAL,CM ,'CM' ,RC=STATUS); VERIFY_(STATUS) call MAPL_GetPointer(INTERNAL,CQ ,'CQ' ,RC=STATUS); VERIFY_(STATUS) call MAPL_GetPointer(INTERNAL,FR ,'FR' ,RC=STATUS); VERIFY_(STATUS) - call MAPL_GetPointer(INTERNAL,DCQ ,'DCQ' ,RC=STATUS); VERIFY_(STATUS) - call MAPL_GetPointer(INTERNAL,DCH ,'DCH' ,RC=STATUS); VERIFY_(STATUS) + call MAPL_GetPointer(INTERNAL,DCQ ,'DCQ' ,RC=STATUS); VERIFY_(STATUS) + call MAPL_GetPointer(INTERNAL,DCH ,'DCH' ,RC=STATUS); VERIFY_(STATUS) if (N_CONST_LAND4SNWALB /= 0) then call MAPL_GetPointer(INTERNAL,RDU001 ,'RDU001' , RC=STATUS); VERIFY_(STATUS) call MAPL_GetPointer(INTERNAL,RDU002 ,'RDU002' , RC=STATUS); VERIFY_(STATUS) @@ -4857,6 +4872,25 @@ subroutine Driver ( RC ) SNOVR, SNONR, SNOVF, SNONF, & ! instantaneous snow albedos on tiles RCONSTIT, UUU, TPSN1OUT1, DRPAR, DFPAR) + + call MAPL_GetResource(MAPL,SURFRC,label='SURFRC:',default='GEOS_SurfaceGridComp.rc',RC=STATUS) ; VERIFY_(STATUS) + SCF = ESMF_ConfigCreate(rc=status) ; VERIFY_(STATUS) + call ESMF_ConfigLoadFile(SCF,SURFRC,rc=status) ; VERIFY_(STATUS) + call MAPL_GetResource(SCF,SNOW_ALBEDO_INFO,Label="SNOW_ALBEDO_INFO:", DEFAULT=0, RC=STATUS) ; VERIFY_(STATUS) + + if (SNOW_ALBEDO_INFO == 1) then + + call MAPL_GetPointer(INTERNAL,SNOWALB ,'SNOWALB' ,RC=STATUS); VERIFY_(STATUS) + + where (SNOWALB > 0. .and. SNOWALB <= 1.) + SNOVR = SNOWALB + SNONR = SNOWALB + SNOVF = SNOWALB + SNONF = SNOWALB + endwhere + + endif ! if SNOW_ALBEDO_INFO + ! -------------------------------------------------------------------------- ! albedo/swnet partitioning ! -------------------------------------------------------------------------- @@ -5535,6 +5569,17 @@ subroutine Driver ( RC ) SNOVR, SNONR, SNOVF, SNONF, & ! instantaneous snow albedos on tiles RCONSTIT, UUU, TPSN1OUT1,DRPAR, DFPAR) + if (SNOW_ALBEDO_INFO == 1) then + + where (SNOWALB > 0. .and. SNOWALB <= 1.) + SNOVR = SNOWALB + SNONR = SNOWALB + SNOVF = SNOWALB + SNONF = SNOWALB + endwhere + + endif ! if SNOW_ALBEDO_INFO + ALBVR = ALBVR *(1.-ASNOW) + SNOVR *ASNOW ALBVF = ALBVF *(1.-ASNOW) + SNOVF *ASNOW ALBNR = ALBNR *(1.-ASNOW) + SNONR *ASNOW diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc index 98900a487..ec7a5f67c 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc @@ -234,3 +234,11 @@ # # GEOSagcm=>PRESCRIBE_DVG: 0 # GEOSldas=>PRESCRIBE_DVG: 0 + +# ---- SNOW ALBEDO +# +# 0 : Snow albedo look-up table (default) +# 1 : Snow albedo derived from MODIS Collection MOD10A1.006 (2000-2022) +# +# GEOSagcm=>SNOW_ALBEDO_INFO: 0 +# GEOSldas=>SNOW_ALBEDO_INFO: 0 From 322d5bce5f80b244d664aa8c49cbc47729898d2c Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Wed, 24 Aug 2022 11:44:19 -0400 Subject: [PATCH 08/77] minor cleanup --- .../GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 | 2 -- .../Utils/Raster/rmTinyCatchParaMod.F90 | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index f8d22c2c7..4a2164fac 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -653,8 +653,6 @@ PROGRAM mkCatchParam endif write (log_file,'(a)')' ' - ! Creating snow_alb_param.dat - ! --------------------------------------------------------------------- if(use_snow_albedo)then tmpstring = 'Step 14: Snow albedo from MODIS' write (log_file,'(a)') trim(tmpstring) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index 91ccd2459..d7c84ac2a 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -89,6 +89,7 @@ SUBROUTINE init_bcs_config (LBSV) GNU = 2.17 use_PEATMAP = .false. jpl_height = .false. + use_snow_albedo= .false. case ("GM4", "ICA") LAIBCS = 'GSWP2' @@ -96,6 +97,7 @@ SUBROUTINE init_bcs_config (LBSV) MODALB = 'MODIS2' use_PEATMAP = .false. jpl_height = .false. + use_snow_albedo= .false. case ("NL3") LAIBCS = 'MODGEO' @@ -103,6 +105,7 @@ SUBROUTINE init_bcs_config (LBSV) MODALB = 'MODIS2' use_PEATMAP = .false. jpl_height = .false. + use_snow_albedo= .false. case ("NL4") LAIBCS = 'MODGEO' @@ -110,6 +113,7 @@ SUBROUTINE init_bcs_config (LBSV) MODALB = 'MODIS2' use_PEATMAP = .false. jpl_height = .true. + use_snow_albedo= .false. case ("NL5") LAIBCS = 'MODGEO' @@ -117,6 +121,7 @@ SUBROUTINE init_bcs_config (LBSV) MODALB = 'MODIS2' use_PEATMAP = .true. jpl_height = .true. + use_snow_albedo= .false. case ("NL6") LAIBCS = 'MODGEO' @@ -132,6 +137,7 @@ SUBROUTINE init_bcs_config (LBSV) MODALB = 'MODIS2' use_PEATMAP = .true. jpl_height = .true. + use_snow_albedo= .false. end select From edf37eab56b1b1412f404d06d3ae62e6512f24d3 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Mon, 29 Aug 2022 07:58:18 -0400 Subject: [PATCH 09/77] add flag so only V06 has snowalb info in catch_params --- .../GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 30 +++--- .../Utils/Raster/make_bcs | 10 +- .../Utils/Raster/mkCatchParam.F90 | 4 +- .../Utils/Raster/mod_process_hres_data.F90 | 102 ++++++++---------- .../Utils/Raster/rmTinyCatchParaMod.F90 | 14 ++- .../Utils/mk_restarts/CatchmentRst.F90 | 15 +-- 6 files changed, 88 insertions(+), 87 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index 981c0eb33..2a4a44659 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -906,6 +906,7 @@ subroutine SetServices ( GC, RC ) RESTART = MAPL_RestartRequired ,& RC=STATUS ) VERIFY_(STATUS) + call MAPL_AddInternalSpec(GC ,& LONG_NAME = 'wetness_at_wilting_point' ,& UNITS = '1' ,& @@ -4872,22 +4873,21 @@ subroutine Driver ( RC ) SNOVR, SNONR, SNOVF, SNONF, & ! instantaneous snow albedos on tiles RCONSTIT, UUU, TPSN1OUT1, DRPAR, DFPAR) - call MAPL_GetResource(MAPL,SURFRC,label='SURFRC:',default='GEOS_SurfaceGridComp.rc',RC=STATUS) ; VERIFY_(STATUS) SCF = ESMF_ConfigCreate(rc=status) ; VERIFY_(STATUS) call ESMF_ConfigLoadFile(SCF,SURFRC,rc=status) ; VERIFY_(STATUS) - call MAPL_GetResource(SCF,SNOW_ALBEDO_INFO,Label="SNOW_ALBEDO_INFO:", DEFAULT=0, RC=STATUS) ; VERIFY_(STATUS) + call MAPL_GetResource(SCF,SNOW_ALBEDO_INFO,Label="SNOW_ALBEDO_INFO:",DEFAULT=0,RC=STATUS) ; VERIFY_(STATUS) if (SNOW_ALBEDO_INFO == 1) then - call MAPL_GetPointer(INTERNAL,SNOWALB ,'SNOWALB' ,RC=STATUS); VERIFY_(STATUS) + call MAPL_GetPointer(INTERNAL,SNOWALB,'SNOWALB',RC=STATUS); VERIFY_(STATUS) - where (SNOWALB > 0. .and. SNOWALB <= 1.) - SNOVR = SNOWALB - SNONR = SNOWALB - SNOVF = SNOWALB - SNONF = SNOWALB - endwhere + where (SNOWALB > 0. .and. SNOWALB <= 1.) + SNOVR = SNOWALB + SNONR = SNOWALB + SNOVF = SNOWALB + SNONF = SNOWALB + endwhere endif ! if SNOW_ALBEDO_INFO @@ -5571,12 +5571,12 @@ subroutine Driver ( RC ) if (SNOW_ALBEDO_INFO == 1) then - where (SNOWALB > 0. .and. SNOWALB <= 1.) - SNOVR = SNOWALB - SNONR = SNOWALB - SNOVF = SNOWALB - SNONF = SNOWALB - endwhere + where (SNOWALB > 0. .and. SNOWALB <= 1.) + SNOVR = SNOWALB + SNONR = SNOWALB + SNOVF = SNOWALB + SNONF = SNOWALB + endwhere endif ! if SNOW_ALBEDO_INFO diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index 2d7935fa9..fa04ecff6 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -105,8 +105,9 @@ echo " ${C2}ICA : Icarus (/discover/nobackup/ltakacs/bcs/Icarus/)" echo " ${C2}NL3 : Icarus-NLv3 (/discover/nobackup/ltakacs/bcs/Icarus-NLv3/)" echo " ${C2}NL4 : NLv4 [SMAP] (/discover/nobackup/projects/gmao/smap/bcs_NLv4/NLv4/)" echo " ${C2}NL5 : NLv5 [SMAP]" -echo " ${C2}NL6 : NLv6 [SMAP with snow albedo from MODIS]" -echo " ${C2}DEV : Development version${CR}" +echo " ${C2}V06 : V06 [NLv3 + JPL Veg Height + Peatlands + snow albedo from MODIS]" +echo " ${C2}V07 : V07 [NLv3 + Peatlands]" +echo " ${C2}V08 : V08 [NLv3 + snow albedo from MODIS]${CR}" echo " " if ( $HELPMODE != YES ) then echo " NOTE: Due to compiler differences, code improvements and bug fixes that" @@ -133,8 +134,9 @@ if ( $HELPMODE != YES ) then $dummy == 'NL3' | \ $dummy == 'NL4' | \ $dummy == 'NL5' | \ - $dummy == 'NL6' | \ - $dummy == 'DEV') then + $dummy == 'V06' | \ + $dummy == 'V07' | \ + $dummy == 'V08') then set lbcsv = $dummy else if ( $dummy == '' ) then echo $lbcsv diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index 4a2164fac..2a506c897 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -109,7 +109,7 @@ PROGRAM mkCatchParam USAGE(5) =" -b: Position of the dateline in the first grid box (DC or DE). DEFAULT: DC " USAGE(6) =" -e: EASE : This is optional if catchment.def file is available already or " USAGE(7) =" the til file format is pre-Fortuna-2. " - USAGE(8) =" -v LBCSV : Choose bcs version (F25, GM4, ICA, NL3, NL4, NL5, or DEV) " + USAGE(8) =" -v LBCSV : Choose bcs version (F25, GM4, ICA, NL3, NL4, NL5, V06, V07 and V08) " ! Process Arguments !------------------ @@ -249,7 +249,7 @@ PROGRAM mkCatchParam close (10, status = 'keep') inquire(file='clsm/catch_params.nc4', exist=file_exists) - if (.not.file_exists) CALL open_landparam_nc4_files(N_tile) + if (.not.file_exists) CALL open_landparam_nc4_files(N_tile,use_snow_albedo) ! Creating cti_stats.dat ! ---------------------- diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index 0f31beed6..184209d61 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -2989,8 +2989,8 @@ END SUBROUTINE hres_gswp2 SUBROUTINE soil_snow_alb (nx,ny,gfiler) -! Implement snow albedo calculated from MOIDS 22-year climatology. Store snow albedo -! values in clsm/catch_params.nc4 +! Implement snow albedo calculated from MOIDS 22-year climatology. +! Store snow albedo values in clsm/catch_params.nc4 ! Biljana Orescanin July 2022, SSAI@NASA implicit none @@ -3000,7 +3000,7 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) character*200 :: fname character*2 :: vv,hh - integer :: n,maxcat,i,j,k,ncid,status + integer :: n,maxcat,j,ncid,status real,allocatable,dimension(:) :: min_lon,max_lon,min_lat,max_lat,snw_alb integer(kind=4),parameter :: xdim = 1200, ydim = 1200 real,parameter :: alb_res=10.0/1200.0 @@ -3009,28 +3009,28 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) real,dimension(xdim,ydim) :: stch_snw_alb_tmp real,dimension(36,18,xdim,ydim) :: stch_snw_alb real :: minlon,maxlon,minlat,maxlat,pad_lon,pad_lat - real :: sno_alb_cnt, sno_alb_sum,sno_alb_cnt2,sno_alb_sum2 + real :: sno_alb_cnt,sno_alb_sum,sno_alb_cnt2,sno_alb_sum2 integer :: vvtil_min,hhtil_min,vvtil_max,hhtil_max,hhtil,vvtil integer :: tindex1,pfaf1 - integer(kind=4) :: dummy,VarID,varid1,varid2,varid3 + integer(kind=4) :: dummy,varid1,varid2,varid3 integer(kind=4) :: imin,imax,jmin,jmax integer(kind=4) :: imin2,imax2,jmin2,jmax2,count_init_invalid - logical :: file_exists + logical :: file_exists ! Read number of catchment-tiles (maxcat) from catchment.def file fname='clsm/catchment.def' open (10,file=fname,status='old',action='read',form='formatted') read(10,*) maxcat - ! read min/max lat/lons, so those can be used to locate - ! snow albedo grids in the stitched MODIS albedo file + ! Read min/max lat/lons to use when locating snow albedo grids in + ! the stitched MODIS albedo file allocate (min_lon(1:maxcat)) allocate (min_lat(1:maxcat)) allocate (max_lon(1:maxcat)) allocate (max_lat(1:maxcat)) allocate (snw_alb(1:maxcat)) - ! before populating, set all snow albedo values to missing + ! Start by setting all snow albedo values to missing snw_alb(:)=-9999.0 do n = 1, maxcat @@ -3057,21 +3057,21 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) close (10,status='keep') !------------ Get the information on snow albedo ----- - ! ----------- The information on snow albedo is stored in 10x10 30-arcsec files. Read in this - ! information. Then loop over tiles to find a corresponding snow albedo mean + ! ----------- The information on snow albedo is stored in 10x10deg 30-arcsec resolution files. + ! ----------- Read in this information, then loop over the tiles to find a corresponding snow albedo. - ! read in all 10x10deg snow albedo files into a single [36,18,1200,1200] array - do hhtil=1,36 ! loop over all horziontal input files - do vvtil=1,18 ! loop over all vertical input files + ! Read in all 10x10deg snow albedo files into a single [36,18,1200,1200] array + do hhtil=1,36 ! loop over input files - horizontal direction + do vvtil=1,18 ! loop over input files - vertical direction write(vv,'(i2.2)') vvtil write(hh,'(i2.2)') hhtil fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v1/snow_alb_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' - ! Open the file. NF90_NOWRITE tells netCDF we want read-only access to the file. - status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) - ! Get the varid of the data variable, based on its name. + ! Open the file. (NF90_NOWRITE ensures read-only access to the file) + status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) + ! Based on vars name, get the varids. status=NF_INQ_VARID(ncid,'Snow_Albedo',VarID1) ; VERIFY_(STATUS) status=NF_INQ_VARID(ncid,'lon' ,VarID2) ; VERIFY_(STATUS) status=NF_INQ_VARID(ncid,'lat' ,VarID3) ; VERIFY_(STATUS) @@ -3082,42 +3082,36 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) ! Close the file, freeing all resources. status=NF_CLOSE(ncid); VERIFY_(STATUS) - ! store into large aray + ! Store snow albedo values into a single 4D aray stch_snw_alb(hhtil,vvtil,:,:)=stch_snw_alb_tmp enddo enddo - ! open the file to write snow albedo output in -! fname ='clsm/snow_alb_param.dat' -! open(11,file=trim(fname),form='formatted',status='unknown',action = 'write') - ! loop over tiles print*, 'Starting tile loop for snow albedo. ' - count_init_invalid=0 ! counter for non-valid snow albedo after matching tile size + count_init_invalid=0 ! counter for non-valid snow albedo avalues (informational use only; not needed for) - do n = 1, maxcat ! loop over tile + do n = 1, maxcat ! loop over tiles - ! set the current tile snow albedo to missing. Then start calculations to see if not missing. + ! Start by setting snow albedo to missing snw_alb(n)=-9999.0 - ! set sums and counts to zero - sno_alb_sum=0. - sno_alb_cnt=0. + ! Set sums and counts to zero + sno_alb_sum =0. + sno_alb_cnt =0. sno_alb_sum2=0. sno_alb_cnt2=0. - ! This tile has min/max lat/lon info. Use this info to identify which 10x10deg - ! snow albedo file(s) to read in (and then loop over these files). - ! Using ceiling and floor for max and min range, the "halo" approach is - ! implemented. + ! Use tile's min/max lat/lon info to identify the 10x10deg input file(s) + ! and read in snow albedo value(s). The "ceiling" and "floor" implements the "halo". vvtil_min= floor((min_lat(n)+ 90.0)/10.) hhtil_min= floor((min_lon(n)+180.0)/10.) vvtil_max=ceiling((max_lat(n)+ 90.0)/10.) hhtil_max=ceiling((max_lon(n)+180.0)/10.) - ! make sure vv's and hh's are within the range - ! if min>max, swap them + ! Safety checks: + ! 1. Make sure vv's and hh's are within the range. If min>max, swap them. if (vvtil_min .gt. vvtil_max) then dummy =vvtil_min vvtil_min=vvtil_max @@ -3129,27 +3123,27 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) hhtil_max=dummy endif - ! if beyond the range, bring them back + ! 2. Keep within the range. vvtil_min=max(vvtil_min,1) vvtil_max=min(vvtil_max,18) hhtil_min=max(hhtil_min,1) hhtil_max=min(hhtil_max,36) - do hhtil=hhtil_min,hhtil_max ! loop over all horziontal input files - do vvtil=vvtil_min,vvtil_max ! loop over all vertical input files + do hhtil=hhtil_min,hhtil_max ! loop over input files - horzontal direction + do vvtil=vvtil_min,vvtil_max ! loop over input files - vertical direction - ! find indices covered by the tile + ! Find indices ranges corresponding to the current tile area. imin=floor((min_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) imax=floor((max_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) jmin=floor((min_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) jmax=floor((max_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) - ! make sure to stay within the range + ! Keep within the range. imin=max(imin,1) imax=min(imax,xdim) jmin=max(jmin,1) jmax=min(jmax,ydim) - ! sum snow albedo values and counts for current tile corresponding indices + ! Generate sums and counts using current tile corresponding indices sno_alb_sum= sno_alb_sum + & sum(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax), & stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & @@ -3161,14 +3155,15 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) end do ! vvtil end do ! hhtil - ! get mean snow albedo over the tile + + ! Calculate snow albedo for the current tile snw_alb(n) = sno_alb_sum / max(1.0,sno_alb_cnt) if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=-9999.0 !1.E15 - ! if no valid solition, and if tile size is smaller than the snow albedo grid box, - ! then expand the search areaby 1 tile in each direction + ! If no valid solition found, and if the tile size smaller than the snow albedo resolution, + ! expand the search area by 1-tile padding. - ! size of a tile (in both directions) + ! Size of a tile (in both directions) pad_lon=(max_lon(n)-min_lon(n)) pad_lat=(max_lat(n)-min_lat(n)) @@ -3176,10 +3171,10 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) count_init_invalid=count_init_invalid+1 - do hhtil=hhtil_min,hhtil_max ! loop over all horziontal input files - do vvtil=vvtil_min,vvtil_max ! loop over all vertical input files + do hhtil=hhtil_min,hhtil_max ! loop over input files - horzontal direction + do vvtil=vvtil_min,vvtil_max ! loop over input files - vertical direction - ! find indices of snow albedo array corresponding to the current tile + ! Repeat the steps for extracting snow albedo value imin2=floor((min_lon(n)-pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) imax2=floor((max_lon(n)+pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) jmin2=floor((min_lat(n)-pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) @@ -3189,7 +3184,6 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) jmin2=max(jmin2,1) jmax2=min(jmax2,ydim) - ! sum snow albedo values and counts for current tile corresponding indices sno_alb_sum2= sno_alb_sum2 + & sum(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2), & stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & @@ -3207,9 +3201,6 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) endif - ! write the current tile value into the filr -! write (11,'(i10,i8,f13.4)') tindex1,pfaf1,snw_alb(n) - end do ! n-loop over tiles ! write snow albedo into clsm/catch_params.nc4 @@ -3221,11 +3212,6 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) STATUS = NF_CLOSE (NCID) ; VERIFY_(STATUS) endif -! ! close the output file -! write (11,'(a)')' ' -! write (11,'(a)')'TileIndex PfafID snw_alb' -! close (11, status = 'keep') - print*, 'Ended tile loop for snow albedo. ' print*, 'There has been ',count_init_invalid,' inital non-valid snow values (out of',maxcat,')' @@ -6093,12 +6079,13 @@ END SUBROUTINE gimms_clim_ndvi ! -------------------------------------------------------------------------- - SUBROUTINE open_landparam_nc4_files(N_tile) + SUBROUTINE open_landparam_nc4_files(N_tile,use_snow_albedo) implicit none integer :: NCCatOUTID, NCCatCNOUTID, NCVegOUTID integer :: STATUS, CellID1, CellID2, CellID3, SubID integer, intent (in) :: N_tile + logical, intent (in) :: use_snow_albedo integer, dimension(8) :: date_time_values character (22) :: time_stamp character (100) :: MYNAME @@ -6142,6 +6129,7 @@ SUBROUTINE open_landparam_nc4_files(N_tile) call DEF_VAR ( NCCatOUTID, CellID1,'TSB2' ,'water_transfer_param_4' ,'1' ) call DEF_VAR ( NCCatOUTID, CellID1,'WPWET' ,'wetness_at_wilting_point' ,'1' ) call DEF_VAR ( NCCatOUTID, CellID1,'DP2BR' ,'depth_to_bedrock' ,'mm' ) + if (use_snow_albedo) & call DEF_VAR ( NCCatOUTID, CellID1,'SNOWALB' ,'snow_albedo' ,'1' ) call DEF_VAR ( NCVegOUTID, CellID3,'ITY' ,'vegetation_type' ,'1' ) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index d7c84ac2a..4ad1a859d 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -123,7 +123,7 @@ SUBROUTINE init_bcs_config (LBSV) jpl_height = .true. use_snow_albedo= .false. - case ("NL6") + case ("V06") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' @@ -131,13 +131,21 @@ SUBROUTINE init_bcs_config (LBSV) jpl_height = .true. use_snow_albedo= .true. - case ("DEV") + case ("V07") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' use_PEATMAP = .true. - jpl_height = .true. + jpl_height = .false. use_snow_albedo= .false. + + case ("V08") + LAIBCS = 'MODGEO' + SOILBCS = 'HWSD' + MODALB = 'MODIS2' + use_PEATMAP = .false. + jpl_height = .false. + use_snow_albedo= .true. end select diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index b2ece52ff..eca9d5e66 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -485,10 +485,10 @@ subroutine allocate_catch(this,rc) allocate( this% ghtcnt6(ntiles) ) if (this%meta%has_variable('TSURF')) then - allocate( this% tsurf(ntiles) ) + allocate( this% tsurf(ntiles) ) endif if (this%meta%has_variable('SNOWALB')) then - allocate( this% snowalb(ntiles) ) + allocate( this% snowalb(ntiles) ) endif allocate( this% wesnn1(ntiles) ) @@ -537,10 +537,10 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) logical :: file_exists type(NetCDF4_Fileformatter) :: CatchFmt - type(Variable) :: var - type(FileMetadata) :: meta_ + type(Variable) :: var + type(FileMetadata) :: meta_ - character*256 :: Iam = "add_bcs" + character*256 :: Iam = "add_bcs" ntiles = this%ntiles @@ -621,8 +621,10 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) call MAPL_VarRead ( CatchFmt ,'WPWET', this%WPWET, __RC__) call MAPL_VarRead ( CatchFmt ,'DP2BR', DP2BR, __RC__) call MAPL_VarRead ( CatchFmt ,'POROS', this%POROS, __RC__) + meta_ = CatchFmt%read(__RC__) - if ( meta_%has_variable('SNOWALB')) then + + if (meta_%has_variable('SNOWALB')) then if ( .not. allocated(this%snowalb)) allocate(this%snowalb(ntiles)) call MAPL_VarRead ( CatchFmt ,'SNOWALB', this%snowalb, __RC__) if ( .not. this%meta%has_variable('SNOWALB')) then @@ -1091,6 +1093,7 @@ subroutine re_tile(this, InTileFile, OutBcsDir, OutTileFile, surflay, rc) var_out = this%tsurf(id_glb(:)) this%tsurf = var_out endif + if (this%meta%has_variable('SNOWALB')) then var_out = this%snowalb(id_glb(:)) this%snowalb = var_out From cc188a93f16ee1f44064cfa90fc421593a2d1f7d Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Fri, 2 Sep 2022 09:25:34 -0400 Subject: [PATCH 10/77] version to lower case v --- .../GEOSsurface_GridComp/Utils/Raster/make_bcs | 12 ++++++------ .../Utils/Raster/mkCatchParam.F90 | 2 +- .../Utils/Raster/rmTinyCatchParaMod.F90 | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index fa04ecff6..b6b46c6fd 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -105,9 +105,9 @@ echo " ${C2}ICA : Icarus (/discover/nobackup/ltakacs/bcs/Icarus/)" echo " ${C2}NL3 : Icarus-NLv3 (/discover/nobackup/ltakacs/bcs/Icarus-NLv3/)" echo " ${C2}NL4 : NLv4 [SMAP] (/discover/nobackup/projects/gmao/smap/bcs_NLv4/NLv4/)" echo " ${C2}NL5 : NLv5 [SMAP]" -echo " ${C2}V06 : V06 [NLv3 + JPL Veg Height + Peatlands + snow albedo from MODIS]" -echo " ${C2}V07 : V07 [NLv3 + Peatlands]" -echo " ${C2}V08 : V08 [NLv3 + snow albedo from MODIS]${CR}" +echo " ${C2}v06 : v06 [NLv3 + JPL Veg Height + Peatlands + snow albedo from MODIS]" +echo " ${C2}v07 : v07 [NLv3 + Peatlands]" +echo " ${C2}v08 : v08 [NLv3 + snow albedo from MODIS]${CR}" echo " " if ( $HELPMODE != YES ) then echo " NOTE: Due to compiler differences, code improvements and bug fixes that" @@ -134,9 +134,9 @@ if ( $HELPMODE != YES ) then $dummy == 'NL3' | \ $dummy == 'NL4' | \ $dummy == 'NL5' | \ - $dummy == 'V06' | \ - $dummy == 'V07' | \ - $dummy == 'V08') then + $dummy == 'v06' | \ + $dummy == 'v07' | \ + $dummy == 'v08') then set lbcsv = $dummy else if ( $dummy == '' ) then echo $lbcsv diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index 2a506c897..0d4ef824f 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -109,7 +109,7 @@ PROGRAM mkCatchParam USAGE(5) =" -b: Position of the dateline in the first grid box (DC or DE). DEFAULT: DC " USAGE(6) =" -e: EASE : This is optional if catchment.def file is available already or " USAGE(7) =" the til file format is pre-Fortuna-2. " - USAGE(8) =" -v LBCSV : Choose bcs version (F25, GM4, ICA, NL3, NL4, NL5, V06, V07 and V08) " + USAGE(8) =" -v LBCSV : Choose bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07 and v08) " ! Process Arguments !------------------ diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index 4ad1a859d..9e37252f4 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -123,7 +123,7 @@ SUBROUTINE init_bcs_config (LBSV) jpl_height = .true. use_snow_albedo= .false. - case ("V06") + case ("v06") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' @@ -131,7 +131,7 @@ SUBROUTINE init_bcs_config (LBSV) jpl_height = .true. use_snow_albedo= .true. - case ("V07") + case ("v07") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' @@ -139,7 +139,7 @@ SUBROUTINE init_bcs_config (LBSV) jpl_height = .false. use_snow_albedo= .false. - case ("V08") + case ("v08") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' From d58f3460d2335aa2277a2c887136e0e9a46943f5 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Fri, 2 Sep 2022 17:43:01 -0400 Subject: [PATCH 11/77] =?UTF-8?q?cleanup=20and=20improved=20documentation?= =?UTF-8?q?=20-=20clarified=20that=20MODIS-based=20snow=20albedo=20option?= =?UTF-8?q?=20falls=20back=20to=20look-up=20table=20values=20where=20MODIS?= =?UTF-8?q?=20data=20are=20not=20available=20-=20clarified=20that=20MODIS-?= =?UTF-8?q?based=20snow=20albedo=20is=20not=20yet=20available=20for=20Catc?= =?UTF-8?q?hCN=20-=20moved=20processing=20of=20=E2=80=9CSNOW=5FALBEDO=5FIN?= =?UTF-8?q?FO:=E2=80=9D=20into=20SetServices()=20-=20cleaned=20up=20lists?= =?UTF-8?q?=20of=20available=20bcs=20versions=20-=20changed=20name=20of=20?= =?UTF-8?q?subroutine=20that=20processes=20MODIS=20snow=20albedo=20to=20mo?= =?UTF-8?q?re=20intuitive=20=E2=80=9CMODIS=5Fsnow=5Falb()=E2=80=9D=20-=20f?= =?UTF-8?q?ixed=20typos=20in=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GEOS_CatchCNGridComp.F90 | 10 +++- .../GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 57 ++++++++++--------- .../Shared/GEOS_SurfaceGridComp.rc | 16 +++--- .../Utils/Raster/make_bcs | 12 ++-- .../Utils/Raster/mkCatchParam.F90 | 20 +++---- .../Utils/Raster/mod_process_hres_data.F90 | 22 +++---- 6 files changed, 75 insertions(+), 62 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 index b569ac07c..fab9000a2 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 @@ -50,7 +50,7 @@ subroutine SetServices ( GC, RC ) character(len=ESMF_MAXSTR) :: CATCHCN_VERSION character(len=ESMF_MAXSTR) :: SURFRC type(ESMF_Config) :: SCF - integer :: DO_GOSWIM, LSM_CHOICE, ATM_CO2 + integer :: DO_GOSWIM, LSM_CHOICE, ATM_CO2, SNOW_ALBEDO_INFO ! Begin... ! -------- @@ -69,6 +69,14 @@ subroutine SetServices ( GC, RC ) SCF = ESMF_ConfigCreate(rc=status) ; VERIFY_(STATUS) call ESMF_ConfigLoadFile(SCF,SURFRC,rc=status) ; VERIFY_(STATUS) call ESMF_ConfigGetAttribute (SCF, label='ATM_CO2:', value=ATM_CO2, DEFAULT=2, RC=STATUS) ; VERIFY_(STATUS) + + ! SNOW ALBEDO -- so far, only parameterization based on look-up table is implemented for CatchCN + ! 0 : parameterization based on look-up table + ! 1 : MODIS-derived snow albedo (where available, elsewhere fall back to option 0) + call ESMF_ConfigGetAttribute (SCF, label='SNOW_ALBEDO_INFO:', value=SNOW_ALBEDO_INFO, DEFAULT=0, RC=STATUS) ; VERIFY_(STATUS) + + _ASSERT( SNOW_ALBEDO_INFO==0, "SNOW_ALBEDO_INFO must be 0 for CatchCN") + call ESMF_ConfigGetAttribute (SCF, label='N_CONST_LAND4SNWALB:' , value=DO_GOSWIM , DEFAULT=0, RC=STATUS); VERIFY_(STATUS) if ( LSM_CHOICE == 2 ) then diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index 2a4a44659..0795918ae 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -136,7 +136,8 @@ module GEOS_CatchGridCompMod end type CATCH_WRAP !#-- -integer :: USE_ASCATZ0, Z0_FORMULATION, AEROSOL_DEPOSITION, N_CONST_LAND4SNWALB,CHOOSEMOSFC +integer :: USE_ASCATZ0, Z0_FORMULATION, AEROSOL_DEPOSITION, N_CONST_LAND4SNWALB +integer :: CHOOSEMOSFC, SNOW_ALBEDO_INFO real :: SURFLAY ! Default (Ganymed-3 and earlier) SURFLAY=20.0 for Old Soil Params ! (Ganymed-4 and later ) SURFLAY=50.0 for New Soil Params real :: FWETC, FWETL @@ -227,15 +228,21 @@ subroutine SetServices ( GC, RC ) call MAPL_GetResource (SCF, FWETL, label='FWETL:', DEFAULT=0.025, __RC__ ) endif - ! GOSWIM ANOW_ALBEDO + ! SNOW ALBEDO + ! 0 : parameterization based on look-up table + ! 1 : MODIS-derived snow albedo (where available, elsewhere fall back to option 0) + call MAPL_GetResource (SCF, SNOW_ALBEDO_INFO, label='SNOW_ALBEDO_INFO:', DEFAULT=0, __RC__ ) + + ! GOSWIM SNOW_ALBEDO ! 0 : GOSWIM snow albedo scheme is turned off ! 9 : i.e. N_CONSTIT in Stieglitz to turn on GOSWIM snow albedo scheme - call MAPL_GetResource (SCF, N_CONST_LAND4SNWALB, label='N_CONST_LAND4SNWALB:', DEFAULT=0 , __RC__ ) + call MAPL_GetResource (SCF, N_CONST_LAND4SNWALB, label='N_CONST_LAND4SNWALB:', DEFAULT=0, __RC__ ) ! 1: Use all GOCART aerosol values, 0: turn OFF everythying, ! 2: turn off dust ONLY,3: turn off Black Carbon ONLY,4: turn off Organic Carbon ONLY ! __________________________________________ - call MAPL_GetResource (SCF, AEROSOL_DEPOSITION, label='AEROSOL_DEPOSITION:', DEFAULT=0 , __RC__ ) + call MAPL_GetResource (SCF, AEROSOL_DEPOSITION, label='AEROSOL_DEPOSITION:', DEFAULT=0, __RC__ ) + call ESMF_ConfigDestroy(SCF, __RC__) ! Set the Run entry points @@ -4145,9 +4152,6 @@ subroutine Driver ( RC ) integer :: nDims,dimSizes(3) integer :: ldas_ens_id, ldas_first_ens_id - integer :: SNOW_ALBEDO_INFO - character(len=ESMF_MAXSTR) :: SURFRC - type(ESMF_Config) :: SCF !#--- ! -------------------------------------------------------------------------- @@ -4869,27 +4873,24 @@ subroutine Driver ( RC ) RHOFS, & SNWALB_VISMAX, SNWALB_NIRMAX, SLOPE, & WESNN, HTSNNN, SNDZN, & - ALBVR, ALBNR, ALBVF, ALBNF, & ! instantaneous snow-free albedos on tiles - SNOVR, SNONR, SNOVF, SNONF, & ! instantaneous snow albedos on tiles + ALBVR, ALBNR, ALBVF, ALBNF, & ! instantaneous snow-free albedos on tiles + SNOVR, SNONR, SNOVF, SNONF, & ! instantaneous snow albedos on tiles RCONSTIT, UUU, TPSN1OUT1, DRPAR, DFPAR) - call MAPL_GetResource(MAPL,SURFRC,label='SURFRC:',default='GEOS_SurfaceGridComp.rc',RC=STATUS) ; VERIFY_(STATUS) - SCF = ESMF_ConfigCreate(rc=status) ; VERIFY_(STATUS) - call ESMF_ConfigLoadFile(SCF,SURFRC,rc=status) ; VERIFY_(STATUS) - call MAPL_GetResource(SCF,SNOW_ALBEDO_INFO,Label="SNOW_ALBEDO_INFO:",DEFAULT=0,RC=STATUS) ; VERIFY_(STATUS) - if (SNOW_ALBEDO_INFO == 1) then - - call MAPL_GetPointer(INTERNAL,SNOWALB,'SNOWALB',RC=STATUS); VERIFY_(STATUS) - - where (SNOWALB > 0. .and. SNOWALB <= 1.) - SNOVR = SNOWALB - SNONR = SNOWALB - SNOVF = SNOWALB - SNONF = SNOWALB - endwhere - - endif ! if SNOW_ALBEDO_INFO + + ! where available, use MODIS-derived snow albedo from bcs (via Catch restart) + + call MAPL_GetPointer(INTERNAL,SNOWALB,'SNOWALB',RC=STATUS); VERIFY_(STATUS) + + where (SNOWALB > 0. .and. SNOWALB <= 1.) + SNOVR = SNOWALB + SNONR = SNOWALB + SNOVF = SNOWALB + SNONF = SNOWALB + endwhere + + endif ! -------------------------------------------------------------------------- ! albedo/swnet partitioning @@ -5570,7 +5571,9 @@ subroutine Driver ( RC ) RCONSTIT, UUU, TPSN1OUT1,DRPAR, DFPAR) if (SNOW_ALBEDO_INFO == 1) then - + + ! where available, use MODIS-derived snow albedo from bcs (via Catch restart) + where (SNOWALB > 0. .and. SNOWALB <= 1.) SNOVR = SNOWALB SNONR = SNOWALB @@ -5578,7 +5581,7 @@ subroutine Driver ( RC ) SNONF = SNOWALB endwhere - endif ! if SNOW_ALBEDO_INFO + endif ALBVR = ALBVR *(1.-ASNOW) + SNOVR *ASNOW ALBVF = ALBVF *(1.-ASNOW) + SNOVF *ASNOW diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc index ec7a5f67c..cf36809ae 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc @@ -114,6 +114,14 @@ # # GEOSagcm=>MODIS_DVG: 0 # NOT yet used in GEOSldas +# ---- SNOW ALBEDO +# +# 0 : Snow albedo parameterization based on look-up table (default) +# 1 : Snow albedo derived from MODIS Collection MOD10A1.006 (2000-2022) [NOT YET AVAILABLE FOR CatchCN] +# where available, elsewhere fall back to option 0 +# +# GEOSagcm=>SNOW_ALBEDO_INFO: 0 +# GEOSldas=>SNOW_ALBEDO_INFO: 0 #--------------------------------------------------------# # GOSWIM aerosol deposition on surface snow # @@ -235,10 +243,4 @@ # GEOSagcm=>PRESCRIBE_DVG: 0 # GEOSldas=>PRESCRIBE_DVG: 0 -# ---- SNOW ALBEDO -# -# 0 : Snow albedo look-up table (default) -# 1 : Snow albedo derived from MODIS Collection MOD10A1.006 (2000-2022) -# -# GEOSagcm=>SNOW_ALBEDO_INFO: 0 -# GEOSldas=>SNOW_ALBEDO_INFO: 0 + diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index b6b46c6fd..28078e395 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -103,12 +103,12 @@ echo " ${C2}F25 : Fortuna-2_5" echo " ${C2}GM4 : Ganymed-4_0 (/discover/nobackup/ltakacs/bcs/Ganymed-4_0/)" echo " ${C2}ICA : Icarus (/discover/nobackup/ltakacs/bcs/Icarus/)" echo " ${C2}NL3 : Icarus-NLv3 (/discover/nobackup/ltakacs/bcs/Icarus-NLv3/)" -echo " ${C2}NL4 : NLv4 [SMAP] (/discover/nobackup/projects/gmao/smap/bcs_NLv4/NLv4/)" -echo " ${C2}NL5 : NLv5 [SMAP]" -echo " ${C2}v06 : v06 [NLv3 + JPL Veg Height + Peatlands + snow albedo from MODIS]" -echo " ${C2}v07 : v07 [NLv3 + Peatlands]" -echo " ${C2}v08 : v08 [NLv3 + snow albedo from MODIS]${CR}" -echo " " +echo " ${C2}NL4 : NLv4 [SMAP] {NLv3 + JPL veg height} (/discover/nobackup/projects/gmao/smap/bcs_NLv4/NLv4/)" +echo " ${C2}NL5 : NLv5 [SMAP] {NLv3 + JPL veg height + PEATMAP}" +echo " ${C2}v06 : v06 {NLv3 + JPL veg height + PEATMAP + MODIS snow alb}" +echo " ${C2}v07 : v07 {NLv3 + PEATMAP}" +echo " ${C2}v08 : v08 {NLv3 + MODIS snow alb}${CR}" +echo " " if ( $HELPMODE != YES ) then echo " NOTE: Due to compiler differences, code improvements and bug fixes that" echo " have taken place since the above archived BCs were created, some parameter" diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index 0d4ef824f..163b3d80b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -9,7 +9,7 @@ PROGRAM mkCatchParam ! -y: Size of latitude dimension of input raster. DEFAULT: 4320 ! -b: position of the dateline in the first box. DEFAULT: DC ! -g: Gridname (name of the .til or .rst file without file extension) -! -v: LBCSV : Choose bcs version (ICA, NL3, NL4, NL5, or development) +! -v: LBCSV : Choose bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) ! -e: EASE : This is optional if catchment.def file is available already or ! the til file format is pre-Fortuna-2. ! @@ -21,7 +21,7 @@ PROGRAM mkCatchParam ! Sarith Mahanama - March 23, 2012 ! Email: sarith.p.mahanama@nasa.gov - use rmTinyCatchParaMod + use rmTinyCatchParaMod ! includes: use_snow_albedo use process_hres_data ! use module_irrig_params, ONLY : create_irrig_params @@ -109,7 +109,7 @@ PROGRAM mkCatchParam USAGE(5) =" -b: Position of the dateline in the first grid box (DC or DE). DEFAULT: DC " USAGE(6) =" -e: EASE : This is optional if catchment.def file is available already or " USAGE(7) =" the til file format is pre-Fortuna-2. " - USAGE(8) =" -v LBCSV : Choose bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07 and v08) " + USAGE(8) =" -v LBCSV : Choose bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) " ! Process Arguments !------------------ @@ -654,13 +654,13 @@ PROGRAM mkCatchParam write (log_file,'(a)')' ' if(use_snow_albedo)then - tmpstring = 'Step 14: Snow albedo from MODIS' - write (log_file,'(a)') trim(tmpstring) - write (log_file,'(a)')' Loading snow albedo...' - call soil_snow_alb (nc,nr,gridnamer) - write (log_file,'(a)')' Done.' - write (log_file,'(a)')' ' - endif ! if use_snow_albedo + tmpstring = 'Step 14: Snow albedo from MODIS' + write (log_file,'(a)') trim(tmpstring) + write (log_file,'(a)')' Creating file...' + call MODIS_snow_alb (nc,nr,gridnamer) + write (log_file,'(a)')' Done.' + write (log_file,'(a)')' ' + endif ! inquire(file='clsm/irrig.dat', exist=file_exists) ! if (.not.file_exists) call create_irrig_params (nc,nr,gridnamer) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index 184209d61..7a64b69cd 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -38,7 +38,7 @@ MODULE process_hres_data private public :: soil_para_hwsd,hres_lai,hres_gswp2, merge_lai_data, grid2tile_modis6 -public :: soil_snow_alb +public :: MODIS_snow_alb public :: modis_alb_on_tiles_high,modis_scale_para_high,hres_lai_no_gswp public :: histogram, create_mapping, esa2mosaic , esa2clm public :: grid2tile_ndep_t2m_alb, CREATE_ROUT_PARA_FILE, map_country_codes, get_country_codes @@ -2987,9 +2987,9 @@ END SUBROUTINE hres_gswp2 !---------------------------------------------------------------------- - SUBROUTINE soil_snow_alb (nx,ny,gfiler) + SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) -! Implement snow albedo calculated from MOIDS 22-year climatology. +! Implement snow albedo calculated from MODIS 22-year climatology. ! Store snow albedo values in clsm/catch_params.nc4 ! Biljana Orescanin July 2022, SSAI@NASA @@ -3129,8 +3129,8 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) hhtil_min=max(hhtil_min,1) hhtil_max=min(hhtil_max,36) - do hhtil=hhtil_min,hhtil_max ! loop over input files - horzontal direction - do vvtil=vvtil_min,vvtil_max ! loop over input files - vertical direction + do hhtil=hhtil_min,hhtil_max ! loop through input files - horizontal direction + do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction ! Find indices ranges corresponding to the current tile area. imin=floor((min_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) @@ -3160,8 +3160,8 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) snw_alb(n) = sno_alb_sum / max(1.0,sno_alb_cnt) if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=-9999.0 !1.E15 - ! If no valid solition found, and if the tile size smaller than the snow albedo resolution, - ! expand the search area by 1-tile padding. + ! If no valid solution found, and if tile size smaller than snow albedo resolution, + ! expand search area by 1-tile padding. ! Size of a tile (in both directions) pad_lon=(max_lon(n)-min_lon(n)) @@ -3171,8 +3171,8 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) count_init_invalid=count_init_invalid+1 - do hhtil=hhtil_min,hhtil_max ! loop over input files - horzontal direction - do vvtil=vvtil_min,vvtil_max ! loop over input files - vertical direction + do hhtil=hhtil_min,hhtil_max ! loop through input files - horizontal direction + do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction ! Repeat the steps for extracting snow albedo value imin2=floor((min_lon(n)-pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) @@ -3213,9 +3213,9 @@ SUBROUTINE soil_snow_alb (nx,ny,gfiler) endif print*, 'Ended tile loop for snow albedo. ' - print*, 'There has been ',count_init_invalid,' inital non-valid snow values (out of',maxcat,')' + print*, 'Initially found ', count_init_invalid, ' tiles with no-data values for snow albedo (out of ', maxcat,')' - END SUBROUTINE soil_snow_alb + END SUBROUTINE MODIS_snow_alb !-------------------------------------------------------------------------------------- From f9a05d8725b8360b9b9cba510cab0e38a1047d2c Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Wed, 7 Sep 2022 18:30:11 -0400 Subject: [PATCH 12/77] Additional documentation and cleanup of snow albedo changes: - Introduced string (SNOWALB) for snow albedo version. - Edited comments. --- .../Utils/Raster/mkCatchParam.F90 | 42 +++++---- .../Utils/Raster/mkSMAPTilesPara_v2.F90 | 6 +- .../Utils/Raster/mod_process_hres_data.F90 | 15 ++-- .../Utils/Raster/rmTinyCatchParaMod.F90 | 88 ++++++++++++------- 4 files changed, 86 insertions(+), 65 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index afbf98d4a..92a744dbb 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -4,14 +4,14 @@ PROGRAM mkCatchParam ! ! !ARGUMENTS: ! -! Usage = "mkCatchParam -x nx -y ny -g Gridname -b DL -v LBSV -e EASE" +! Usage = "mkCatchParam -x nx -y ny -g Gridname -b DL -v LBCSV -e EASE" ! -x: Size of longitude dimension of input raster. DEFAULT: 8640 ! -y: Size of latitude dimension of input raster. DEFAULT: 4320 ! -b: position of the dateline in the first box. DEFAULT: DC ! -g: Gridname (name of the .til or .rst file without file extension) -! -v: LBCSV : Choose bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) -! -e: EASE : This is optional if catchment.def file is available already or -! the til file format is pre-Fortuna-2. +! -v: LBCSV : Land bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) +! -e: EASE : This is optional if catchment.def file is available already or +! the til file format is pre-Fortuna-2. ! ! ! This program is good to generate @@ -21,7 +21,7 @@ PROGRAM mkCatchParam ! Sarith Mahanama - March 23, 2012 ! Email: sarith.p.mahanama@nasa.gov - use rmTinyCatchParaMod ! includes: use_snow_albedo + use rmTinyCatchParaMod use process_hres_data ! use module_irrig_params, ONLY : create_irrig_params @@ -33,7 +33,7 @@ PROGRAM mkCatchParam ! NC and NR are typically overwritten through command-line arguments "-x nx -y ny". integer :: NC = i_raster, NR = j_raster - character*4 :: LBSV = 'DEF' + character*5 :: LBCSV = 'UNDEF' character*128 :: GridName = '' character*128 :: ARG, MaskFile character*256 :: CMD @@ -60,6 +60,7 @@ PROGRAM mkCatchParam character*200 :: tmpstring, tmpstring1, tmpstring2 character*200 :: fname_tmp, fname_tmp2, fname_tmp3, fname_tmp4 integer :: N_tile + logical :: process_snow_albedo = .false. ! --------- VARIABLES FOR *OPENMP* PARALLEL ENVIRONMENT ------------ ! @@ -102,14 +103,14 @@ PROGRAM mkCatchParam ! call execute_command_line('cd data/ ; ln -s /discover/nobackup/projects/gmao/ssd/land/l_data/LandBCs_files_for_mkCatchParam/V001/ CATCH') ! call execute_command_line('cd ..') - USAGE(1) ="Usage: mkCatchParam -x nx -y ny -g Gridname -b DL -v LBCSV -e EASE " - USAGE(2) =" -x: Size of longitude dimension of input raster. DEFAULT: 8640 " - USAGE(3) =" -y: Size of latitude dimension of input raster. DEFAULT: 4320 " - USAGE(4) =" -g: Gridname (name of the .til or .rst file without file extension) " - USAGE(5) =" -b: Position of the dateline in the first grid box (DC or DE). DEFAULT: DC " - USAGE(6) =" -e: EASE : This is optional if catchment.def file is available already or " - USAGE(7) =" the til file format is pre-Fortuna-2. " - USAGE(8) =" -v LBCSV : Choose bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) " + USAGE(1) ="Usage: mkCatchParam -x nx -y ny -g Gridname -b DL -v LBCSV -e EASE " + USAGE(2) =" -x: Size of longitude dimension of input raster. DEFAULT: 8640 " + USAGE(3) =" -y: Size of latitude dimension of input raster. DEFAULT: 4320 " + USAGE(4) =" -g: Gridname (name of the .til or .rst file without file extension) " + USAGE(5) =" -b: Position of the dateline in the first grid box (DC or DE). DEFAULT: DC " + USAGE(6) =" -e: EASE : This is optional if catchment.def file is available already or " + USAGE(7) =" the til file format is pre-Fortuna-2. " + USAGE(8) =" -v LBCSV : Land bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) " ! Process Arguments !------------------ @@ -153,9 +154,9 @@ PROGRAM mkCatchParam case ('g') GridName = trim(arg) case ('v') - LBSV = trim(arg) + LBCSV = trim(arg) if (trim(arg).eq."F25") F25Tag = .true. - call init_bcs_config (trim(LBSV)) + call init_bcs_config (trim(LBCSV)) ! get bcs details from version string case ('b') DL = trim(arg) case ('e') @@ -191,11 +192,14 @@ PROGRAM mkCatchParam if(use_PEATMAP) PEATSOURCE = 'PEATMAP' if(jpl_height) VEGZSOURCE = 'JPL' + if (trim(SNOWALB)=='MODC006')) process_snow_albedo=.true. + if(n_threads == 1) then write (log_file,'(a)')trim(LAIBCS) write (log_file,'(a)')trim(MODALB) write (log_file,'(a)')trim(SOILBCS) + write (log_file,'(a)')trim(SNOWALB) write (log_file,'(a)')trim(MaskFile) write (log_file,'(a)')trim(PEATSOURCE) write (log_file,'(a)')trim(VEGZSOURCE) @@ -249,7 +253,7 @@ PROGRAM mkCatchParam close (10, status = 'keep') inquire(file='clsm/catch_params.nc4', exist=file_exists) - if (.not.file_exists) CALL open_landparam_nc4_files(N_tile,use_snow_albedo) + if (.not.file_exists) CALL open_landparam_nc4_files(N_tile,process_snow_albedo) ! Creating cti_stats.dat ! ---------------------- @@ -653,8 +657,8 @@ PROGRAM mkCatchParam endif write (log_file,'(a)')' ' - if(use_snow_albedo)then - tmpstring = 'Step 14: Snow albedo from MODIS' + if(process_snow_albedo)then + tmpstring = 'Step 14: Static snow albedo from MODIS' write (log_file,'(a)') trim(tmpstring) write (log_file,'(a)')' Creating file...' call MODIS_snow_alb (nc,nr,gridnamer) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index 70025ec11..55c1abc37 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -16,7 +16,7 @@ PROGRAM mkSMAPTilesPara_v2 use LogRectRasterizeMod implicit none - character*4 :: LBSV = 'DEF' + character*5 :: LBCSV = 'UNDEF' integer i,j,ig,jg,i0,iop,n,d1,d2,j1,j2,i1,i2,ix, jx,icount,pcount integer :: NC = i_raster, NR = j_raster, NT = 16330000, ND = 10000, ND_raster = 10000 @@ -95,7 +95,7 @@ PROGRAM mkSMAPTilesPara_v2 elseif ( trim(arg) == '-v' ) then i = i+1 - call get_command_argument(i,LBSV) + call get_command_argument(i,LBCSV) else ! stop for any other arguments @@ -753,7 +753,7 @@ PROGRAM mkSMAPTilesPara_v2 ! now run mkCatchParam ! -------------------- - tmpstring1 = '-e EASE -g '//trim(gfile)//' -v '//trim(LBSV) + tmpstring1 = '-e EASE -g '//trim(gfile)//' -v '//trim(LBCSV) write(tmpstring2,'(2(a2,x,i5,x))')'-x',nc,'-y',nr tmpstring = 'bin/mkCatchParam.x '//trim(tmpstring2)//' '//trim(tmpstring1) print *,trim(tmpstring) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index 8128b7586..92b3b161f 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -2994,9 +2994,9 @@ END SUBROUTINE hres_gswp2 SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) -! Implement snow albedo calculated from MODIS 22-year climatology. -! Store snow albedo values in clsm/catch_params.nc4 -! Biljana Orescanin July 2022, SSAI@NASA + ! Process static snow albedo calculated from MODIS climatology and write into clsm/catch_params.nc4 + ! + ! Biljana Orescanin July 2022, SSAI@NASA implicit none integer, intent (in) :: nx, ny @@ -3099,9 +3099,6 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) do n = 1, maxcat ! loop over tiles - ! Start by setting snow albedo to missing - snw_alb(n)=-9999.0 - ! Set sums and counts to zero sno_alb_sum =0. sno_alb_cnt =0. @@ -6089,13 +6086,13 @@ END SUBROUTINE gimms_clim_ndvi ! -------------------------------------------------------------------------- - SUBROUTINE open_landparam_nc4_files(N_tile,use_snow_albedo) + SUBROUTINE open_landparam_nc4_files(N_tile,process_snow_albedo) implicit none integer :: NCCatOUTID, NCCatCNOUTID, NCVegOUTID integer :: STATUS, CellID1, CellID2, CellID3, SubID integer, intent (in) :: N_tile - logical, intent (in) :: use_snow_albedo + logical, intent (in) :: process_snow_albedo integer, dimension(8) :: date_time_values character (22) :: time_stamp character (100) :: MYNAME @@ -6139,7 +6136,7 @@ SUBROUTINE open_landparam_nc4_files(N_tile,use_snow_albedo) call DEF_VAR ( NCCatOUTID, CellID1,'TSB2' ,'water_transfer_param_4' ,'1' ) call DEF_VAR ( NCCatOUTID, CellID1,'WPWET' ,'wetness_at_wilting_point' ,'1' ) call DEF_VAR ( NCCatOUTID, CellID1,'DP2BR' ,'depth_to_bedrock' ,'mm' ) - if (use_snow_albedo) & + if (process_snow_albedo) & call DEF_VAR ( NCCatOUTID, CellID1,'SNOWALB' ,'snow_albedo' ,'1' ) call DEF_VAR ( NCVegOUTID, CellID3,'ITY' ,'vegetation_type' ,'1' ) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index fb75e1966..2060ca57b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -42,14 +42,19 @@ module rmTinyCatchParaMod public tgen, sat_param,REFORMAT_VEGFILES,base_param,ts_param public :: Get_MidTime, Time_Interp_Fac, compute_stats, c_data public :: ascat_r0, jpl_canoph, NC_VarID, init_bcs_config + INTEGER, PARAMETER, public:: SRTM_maxcat = 291284 - logical, public, save :: use_PEATMAP = .true. - logical, public, save :: jpl_height = .true. - logical, public, save :: use_snow_albedo = .false. - character*8, public, save :: LAIBCS = 'MODGEO' - character*4, public, save :: SOILBCS = 'HWSD' - character*6, public, save :: MODALB = 'MODIS2' - REAL, public, save :: GNU = 1.0 + + ! The following variables define the details of the BCS version (data sources). + ! Initialize to dummy values here and set to desired values in init_bcs_config(). + + logical, public, save :: use_PEATMAP = .false. + logical, public, save :: jpl_height = .false. + character*8, public, save :: LAIBCS = 'UNDEF' + character*4, public, save :: SOILBCS = 'UNDEF' + character*6, public, save :: MODALB = 'UNDEF' + character*8, public, save :: SNOWALB = 'UNDEF' + REAL, public, save :: GNU = MAPL_UNDEF type :: mineral_perc real :: clay_perc @@ -59,93 +64,108 @@ module rmTinyCatchParaMod contains - SUBROUTINE init_bcs_config (LBSV) + SUBROUTINE init_bcs_config (LBCSV) + ! determine BCs details from land BCs version string (LBCSV) + ! + ! LAIBCS: Leaf-Area-Index data set. DEFAULT : MODGEO + ! GLASSA : 8-day AVHRR clim, 1981-2017, 7200x3600 grid + ! GLASSM : 8-day MODIS clim, 2000-2017, 7200x3600 grid + ! MODISV6 : 8-day clim, 2002.01-2016.10, 86400x43200 grid + ! MODGEO : MODIS with GEOLAND2 overlaid on South America, Africa, and Australia + ! GEOLAND2 : 10-day clim, 1999-2011, 40320x20160 grid + ! GSWP2 : Monthly clim, 1982-1998, 360x180 grid + ! MODIS : 8-day clim, 2000-2013, 43200x21600 grid + ! GSWPH : Monthly clim, 1982-1998, 43200x21600 grid + ! + ! MODALB: MODIS Albedo data (snow-free). DEFAULT : MODIS2 + ! MODIS1 : 16-day clim, 1'x1' (21600x10800) MODIS data, 2000-2004 + ! MODIS2 : 8-day clim, 30"x30"(43200x21600) MODIS data, 2001-2011 + ! + ! SNOWALB: Snow albedo data. DEFAULT : LUT + ! LUT : Parameterization based on look-up table values. + ! MODC006 : Static snow albedo derived from MODIS Collection 6 data where available, LUT elsewhere. + ! + ! SOILBCS: Soil parameter data. DEFAULT : HWSD + ! HWSD : Merged HWSD-STATSGO2 soil properties on 43200x21600 with Woesten et al. (1999) parameters + implicit none + + character(*), intent (in) :: LBCSV ! land BCs version - character(*), intent (in) :: LBSV ! LBSV = land BCs version (?) - -! LAIBCS: Choice of LAI data set. DEFAULT : MODGEO -! GLASSA : 8-day AVHRR climatology from the period 1981-2017 on 7200x3600 grid -! GLASSM : 8-day MODIS climatology from the period 2000-2017 on 7200x3600 grid -! MODISV6 : 8-day climatology from the period 2002.01-2016.10 on 86400x43200 grid -! MODGEO : MODIS with GEOLAND2 overlaid on South America, Afirca and Australia -! GEOLAND2: 10-day climatology from the period 1999-2011 on 40320x20160 grid -! GSWP2 : Monthly climatology from the period 1982-1998 on 360x180 grid -! MODIS : 8-day climatology from the period 2000-2013 on 43200x21600 grid -! GSWPH : Monthly climatology from the period 1982-1998 on 43200x21600 grid " -! MODALB: Choice of MODIS Albedo data. DEFAULT : MODIS2 -! MODIS1 : 16-day Climatology from 1'x1 (21600x10800) MODIS data from the period 2000-2004 -! MODIS2 : 8-day Climatology from 30"x30"(43200x21600) MODIS data from the period 2001-2011 -! SOILBCS:Choice of soil data. DEFAULT :HWSD -! HWSD : Merged HWSD-STATSGO2 soil properties on 43200x21600 with Woesten et al. (1999) Parameters - - select case (trim(LBSV)) + select case (trim(LBCSV)) case ("F25") LAIBCS = 'GSWP2' SOILBCS = 'NGDC' MODALB = 'MODIS1' + SNOWALB = 'LUT' GNU = 2.17 use_PEATMAP = .false. jpl_height = .false. - use_snow_albedo= .false. case ("GM4", "ICA") LAIBCS = 'GSWP2' SOILBCS = 'NGDC' MODALB = 'MODIS2' + SNOWALB = 'LUT' + GNU = 1.0 use_PEATMAP = .false. jpl_height = .false. - use_snow_albedo= .false. case ("NL3") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' + SNOWALB = 'LUT' + GNU = 1.0 use_PEATMAP = .false. jpl_height = .false. - use_snow_albedo= .false. case ("NL4") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' + SNOWALB = 'LUT' + GNU = 1.0 use_PEATMAP = .false. jpl_height = .true. - use_snow_albedo= .false. case ("NL5") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' + SNOWALB = 'LUT' + GNU = 1.0 use_PEATMAP = .true. jpl_height = .true. - use_snow_albedo= .false. case ("v06") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' + SNOWALB = 'MODC006' + GNU = 1.0 use_PEATMAP = .true. jpl_height = .true. - use_snow_albedo= .true. case ("v07") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' + SNOWALB = 'LUT' + GNU = 1.0 use_PEATMAP = .true. jpl_height = .false. - use_snow_albedo= .false. case ("v08") LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' + SNOWALB = 'MODC006' + GNU = 1.0 use_PEATMAP = .false. jpl_height = .false. - use_snow_albedo= .true. end select From 85c37079bafc02889b761e5976879fd28aa5db2a Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Wed, 7 Sep 2022 22:27:17 -0400 Subject: [PATCH 13/77] fixed build error in last commit --- .../GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index 2060ca57b..e98bc7f61 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -10,6 +10,7 @@ module rmTinyCatchParaMod use date_time_util use leap_year use MAPL_ConstantsMod + use MAPL_Base, ONLY: MAPL_UNDEF use lsm_routines, ONLY: sibalb implicit none From 034aac09493c2948e681aefa3ed69f2b312fa8e9 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Thu, 8 Sep 2022 08:48:34 -0400 Subject: [PATCH 14/77] fixed another build error in previous commit --- .../GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index 92a744dbb..47878299e 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -192,7 +192,7 @@ PROGRAM mkCatchParam if(use_PEATMAP) PEATSOURCE = 'PEATMAP' if(jpl_height) VEGZSOURCE = 'JPL' - if (trim(SNOWALB)=='MODC006')) process_snow_albedo=.true. + if (trim(SNOWALB)=='MODC006') process_snow_albedo=.true. if(n_threads == 1) then From 18af51be748f8cb74eefa05cdbd1fd01b46a8de4 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 9 Sep 2022 10:41:05 -0400 Subject: [PATCH 15/77] combine easeV1 and easev2 --- .../Utils/Raster/CMakeLists.txt | 5 +- .../Utils/Raster/EASE_conv.F90 | 675 ++++++++++++++++++ .../Utils/Raster/easeV1_conv.F90 | 305 -------- .../Utils/Raster/easeV2_conv.F90 | 317 -------- .../Utils/Raster/mkSMAPTilesPara.F90 | 2 +- .../Utils/Raster/mkSMAPTilesPara_v2.F90 | 99 +-- 6 files changed, 736 insertions(+), 667 deletions(-) create mode 100644 GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 delete mode 100644 GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/easeV1_conv.F90 delete mode 100644 GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/easeV2_conv.F90 diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt index b4b947833..be0b731ce 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt @@ -2,9 +2,8 @@ esma_set_this(OVERRIDE raster) set (srcs date_time_util.F90 leap_year.F90 -easeV1_conv.F90 +EASE_conv.F90 mod_process_hres_data.F90 -easeV2_conv.F90 rasterize.F90 read_riveroutlet.F90 CubedSphere_GridMod.F90 @@ -45,7 +44,7 @@ ecbuild_add_executable (TARGET mkMITAquaRaster.x SOURCES mkMITAquaRaster.F90 LIB ecbuild_add_executable (TARGET mkMOMAquaRaster.x SOURCES mkMOMAquaRaster.F90 LIBS MAPL ${this}) ecbuild_add_executable (TARGET FillMomGrid.x SOURCES FillMomGrid.F90 LIBS MAPL ${this}) ecbuild_add_executable (TARGET mk_runofftbl.x SOURCES mk_runofftbl.F90 LIBS MAPL ${this}) -ecbuild_add_executable (TARGET mkSMAPTilesPara.x SOURCES mkSMAPTilesPara.F90 LIBS MAPL ${this}) +#ecbuild_add_executable (TARGET mkSMAPTilesPara.x SOURCES mkSMAPTilesPara.F90 LIBS MAPL ${this}) ecbuild_add_executable (TARGET mkSMAPTilesPara_v2.x SOURCES mkSMAPTilesPara_v2.F90 LIBS MAPL ${this}) install(PROGRAMS make_bcs clsm_plots.pro plot_curves.pro create_README.csh plot_curves.csh DESTINATION bin) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 new file mode 100644 index 000000000..d41501faf --- /dev/null +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 @@ -0,0 +1,675 @@ + +module EASE_conv + + ! ========================================================================== + ! + ! easeV1_conv.F90 - FORTRAN routines for conversion of azimuthal + ! equal area and equal area cylindrical grid coordinates + ! + ! 30-Jan-1992 H.Maybee + ! 20-Mar-1992 Ken Knowles 303-492-0644 knowles@kryos.colorado.edu + ! 16-Dec-1993 MJ Brodzik 303-492-8263 brodzik@jokull.colorado.edu + ! Copied from nsmconv.f, changed resolutions from + ! 40-20-10 km to 25-12.5 km + ! 21-Dec-1993 MJ Brodzik 303-492-8263 brodzik@jokull.colorado.edu + ! Fixed sign of Southern latitudes in ease_inverse. + ! 12-Sep-1994 David Hoogstrate 303-492-4116 hoogstra@jokull.colorado.edu + ! Changed grid cell size. Changed "c","f" to "l","h" + ! 25-Oct-1994 David Hoogstrate 303-492-4116 hoogstra@jokull.colorado.edu + ! Changed row size from 587 to 586 for Mercator projection + ! 11-May-2011 reichle: Changed "smap" to "easeV1". + ! Added SSM/I and AMSR-E "M25" grid. + ! So far ONLY for cylindrical grids. + ! Converted from *.f to *.F90 module + ! + ! $Log$ + ! Revision 1.1.2.3 2018/09/13 20:42:50 wjiang + ! change M25 + ! + ! Revision 1.1.2.2 2017/09/18 15:10:25 wjiang + ! "fix" strange compiler erro on comment line. + ! + ! Revision 1.1.2.1 2017/01/19 19:35:58 wjiang + ! 1)add EASE grid support + ! 2)add ensemble average for HISTORY + ! + ! Revision 1.2 2014-08-26 17:33:55 rreichle + ! - clean-up of *.F90 in GEOSlana_GridComp: + ! - make sure all modules include "private" statement + ! - follow all "use" statements with "ONLY" + ! - removed unused files (esat_qsat.F90, nr_sort.f) + ! - removed unused variables + ! + ! Revision 1.1 2011-05-11 21:58:46 rreichle + ! + ! Adding utilities to map between EASE grids and lat/lon coordinates. + ! + ! Revision 1.3 1994/11/01 23:40:43 brodzik + ! Replaced all references to 'ease' with 'smap' + ! Replaced all references to 'smap' with 'easeV1' -- reichle + ! + ! ========================================================================== + + implicit none + + private + + public :: ease_convert + public :: ease_inverse +! public :: easeV1_convert +! public :: easeV1_inverse +! public :: easeV2_convert +! public :: easeV2_inverse +! public :: easeV2_extent + + + ! ***NEVER*** change these constants to GEOS-5 MAPL constants!!!! + + ! radius of the earth (km), authalic sphere based on International datum + + real*8, parameter :: RE_km = 6371.228 + + ! scale factor for standard paralles at +/-30.00 degrees + + real*8, parameter :: COS_PHI1 = .866025403 + + real*8, parameter :: PI = 3.14159265358979323846 + + ! ========================================================================== + ! + ! easeV2_conv.F90 - FORTRAN routines for converting grid coordinates + ! (latitude/longitude <--> row/column indices) + ! of the Equal Area Scalable Earth, version 2 (EASEv2) grid + ! + ! ***** ONLY cylindrical ('M') projection implemented ***** + ! + ! Ported from Steven Chan's matlab code (smapease2inverse.m, + ! smapease2forward.m), which has been ported from NSIDC's IDL code + ! (wgs84_convert.pro, wgs84_inverse.pro) available from + ! ftp://sidads.colorado.edu/pub/tools/easegrid/geolocation_tools/ + ! + ! 04-Apr-2013 - reichle + ! + ! Official references: + ! doi:10.3390/ijgi1010032 + ! doi:10.3390/ijgi3031154 -- correction of M25 "map_scale_m" parameters! + ! + ! 04-Apr-2013 - reichle + ! 11-Sep-2018 - reichle, mgirotto -- added 'M25' grid parameters + ! + ! ========================================================================== + + + ! ***NEVER*** change these constants to GEOS-5 MAPL constants!!!! + + ! radius of the earth (m) and map eccentricity + + real*8, parameter :: map_equatorial_radius_m = 6378137.0 + + real*8, parameter :: map_eccentricity = 0.081819190843 + + + real*8, parameter :: e2 = map_eccentricity * map_eccentricity + real*8, parameter :: e4 = e2 * e2 + real*8, parameter :: e6 = e2 * e4 + + real*8, parameter :: epsilon = 1.e-6 + + real*8, parameter :: map_reference_longitude = 0.0 ! 'M', 'N', 'S' + + ! constants for 'N' and 'S' (azimuthal) projections + + real*8, parameter :: N_map_reference_latitude = 90.0 + real*8, parameter :: S_map_reference_latitude = -90.0 + + ! constants for 'M' (cylindrical) projection + + real*8, parameter :: M_map_reference_latitude = 0.0 + real*8, parameter :: M_map_second_reference_latitude = 30.0 + + real*8, parameter :: M_sin_phi1 = sin(M_map_second_reference_latitude*PI/180.) + real*8, parameter :: M_cos_phi1 = cos(M_map_second_reference_latitude*PI/180.) + + real*8, parameter :: M_kz = M_cos_phi1/sqrt(1.0-e2*M_sin_phi1*M_sin_phi1) + + +contains + + subroutine ease_convert (gridname, lat, lon, r, s) + character*(*), intent(in) :: gridname + real, intent(in) :: lat, lon + real, intent(out) :: r, s + character(3) :: grid + + if (index(gridname,'M36') /=0 ) then + grid='M36' + else if (index(gridname,'M25') /=0 ) then + grid='M25' + else if (index(gridname,'M09') /=0 ) then + grid='M09' + else if (index(gridname,'M03') /=0 ) then + grid='M03' + else if (index(gridname,'M01') /=0 ) then + grid='M01' + endif + + if(index(gridname,'EASEv2') /=0) then + call easeV2_convert(grid,lat,lon,r,s) + else if(index(gridname,'EASE') /=0) then + call easeV1_convert(grid,lat,lon,r,s) + else + print*,"wrong gridname: "//gridname + endif + end subroutine + + subroutine ease_inverse (gridname, r, s, lat, lon) + character*(*), intent(in) :: gridname + real, intent(in) :: r, s + real, intent(out) :: lat, lon + character(3) :: grid + + if (index(gridname,'M36') /=0 ) then + grid='M36' + else if (index(gridname,'M25') /=0 ) then + grid='M25' + else if (index(gridname,'M09') /=0 ) then + grid='M09' + else if (index(gridname,'M03') /=0 ) then + grid='M03' + else if (index(gridname,'M01') /=0 ) then + grid='M01' + endif + + if(index(gridname,'EASEv2') /=0) then + call easeV2_inverse(grid,r,s,lat,lon) + else if(index(gridname,'EASE') /=0) then + call easeV1_inverse(grid,r,s,lat,lon) + else + print*,"wrong gridname: "//gridname + endif + end subroutine ease_inverse + + ! ******************************************************************* + + subroutine easeV1_convert (grid, lat, lon, r, s) + + ! convert geographic coordinates (spherical earth) to + ! azimuthal equal area or equal area cylindrical grid coordinates + ! + ! status = easeV1_convert (grid, lat, lon, r, s) + ! + ! input : grid - projection name '[M][xx]' + ! where xx = approximate resolution [km] + ! ie xx = "01", "03", "09", "36" (SMAP) + ! or xx = "12", "25" (SSM/I, AMSR-E) + ! lat, lon = geo. coords. (decimal degrees) + ! + ! output: r, s - column, row coordinates + ! + ! result: status = 0 indicates normal successful completion + ! -1 indicates error status (point not on grid) + ! + ! -------------------------------------------------------------------------- + + character*(*), intent(in) :: grid + real, intent(in) :: lat, lon + real, intent(out) :: r, s + + ! local variables + + integer :: cols, rows + real*8 :: Rg, phi, lam, rho, CELL_km, r0, s0 + + ! --------------------------------------------------------------------- + + call easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) + + phi = lat*PI/180. ! convert from degree to radians + lam = lon*PI/180. ! convert from degree to radians + + if (grid(1:1).eq.'N') then + rho = 2 * Rg * sin(PI/4. - phi/2.) + r = r0 + rho * sin(lam) + s = s0 + rho * cos(lam) + + else if (grid(1:1).eq.'S') then + rho = 2 * Rg * cos(PI/4. - phi/2.) + r = r0 + rho * sin(lam) + s = s0 - rho * cos(lam) + + else if (grid(1:1).eq.'M') then + r = r0 + Rg * lam * COS_PHI1 + s = s0 - Rg * sin(phi) / COS_PHI1 + + endif + + end subroutine easeV1_convert + + ! ******************************************************************* + + subroutine easeV1_inverse (grid, r, s, lat, lon) + + ! convert azimuthal equal area or equal area cylindrical + ! grid coordinates to geographic coordinates (spherical earth) + ! + ! status = easeV1_inverse (grid, r, s, lat, lon) + ! + ! input : grid - projection name '[M][xx]' + ! where xx = approximate resolution [km] + ! ie xx = "01", "03", "09", "36" (SMAP) + ! or xx = "12", "25" (SSM/I, AMSR-E) + ! r, s - column, row coordinates + ! + ! output: lat, lon = geo. coords. (decimal degrees) + ! + ! result: status = 0 indicates normal successful completion + ! -1 indicates error status (point not on grid) + ! + ! -------------------------------------------------------------------------- + + character*(*), intent(in) :: grid + real, intent(in) :: r, s + real, intent(out) :: lat, lon + + ! local variables + + integer :: cols, rows + real*8 :: Rg, phi, lam, rho, CELL_km, r0, s0 + real*8 :: gamma, beta, epsilon, x, y, c + real*8 :: sinphi1, cosphi1 + + ! --------------------------------------------------------------------- + + call easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) + + x = r - r0 + y = -(s - s0) + + if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) then + rho = sqrt(x*x + y*y) + if (rho.eq.0.0) then + if (grid(1:1).eq.'N') lat = 90.0 + if (grid(1:1).eq.'S') lat = -90.0 + lon = 0.0 + else + if (grid(1:1).eq.'N') then + sinphi1 = sin(PI/2.) + cosphi1 = cos(PI/2.) + if (y.eq.0.) then + if (r.le.r0) lam = -PI/2. + if (r.gt.r0) lam = PI/2. + else + lam = atan2(x,-y) + endif + else if (grid(1:1).eq.'S') then + sinphi1 = sin(-PI/2.) + cosphi1 = cos(-PI/2.) + if (y.eq.0.) then + if (r.le.r0) lam = -PI/2. + if (r.gt.r0) lam = PI/2. + else + lam = atan2(x,y) + endif + endif + gamma = rho/(2 * Rg) + if (abs(gamma) .gt. 1.) return + c = 2 * asin(gamma) + beta = cos(c) * sinphi1 + y * sin(c) * (cosphi1/rho) + if (abs(beta).gt.1.) return + phi = asin(beta) + lat = phi*180./PI ! convert from radians to degree + lon = lam*180./PI ! convert from radians to degree + endif + + else if (grid(1:1).eq.'M') then + + ! allow .5 cell tolerance in arcsin function + ! so that grid coordinates which are less than .5 cells + ! above 90.00N or below 90.00S are given a lat of 90.00 + + epsilon = 1 + 0.5/Rg + beta = y*COS_PHI1/Rg + if (abs(beta).gt.epsilon) return + if (beta.le.-1.) then + phi = -PI/2. + else if (beta.ge.1.) then + phi = PI/2. + else + phi = asin(beta) + endif + lam = x/COS_PHI1/Rg + lat = phi*180./PI ! convert from radians to degree + lon = lam*180./PI ! convert from radians to degree + endif + + end subroutine easeV1_inverse + + ! ******************************************************************* + + subroutine easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) + + implicit none + + character*(*), intent(in) :: grid + real*8, intent(out) :: CELL_km, r0, s0, Rg + integer, intent(out) :: cols, rows + + ! -------------------------------------------------------- + ! + ! r0,s0 are defined such that cells at all scales have + ! coincident center points + ! + !c r0 = (cols-1)/2. * scale + !c s0 = (rows-1)/2. * scale + ! + ! -------------------------------------------------------- + + if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) then + + print *,'Polar projections not implemented yet' + stop + + else if (grid(1:1).eq.'M') then + + if (grid .eq. 'M36') then ! SMAP 36 km grid + CELL_km = 36.00040279063 ! nominal cell size in kilometers + cols = 963 + rows = 408 + r0 = 481.0 + s0 = 203.5 + + else if (grid .eq. 'M25') then ! SSM/I, AMSR-E 25 km grid + CELL_km = 25.067525 ! nominal cell size in kilometers + cols = 1383 + rows = 586 + r0 = 691.0 + s0 = 292.5 + + else if (grid .eq. 'M09') then ! SMAP 9 km grid + CELL_km = 9.00010069766 ! nominal cell size in kilometers + cols = 3852 + rows = 1632 + r0 = 1925.5 + s0 = 815.5 + + else if (grid .eq. 'M03') then ! SMAP 3 km grid + CELL_km = 3.00003356589 ! nominal cell size in kilometers + cols = 11556 + rows = 4896 + r0 = 5777.5 + s0 = 2447.5 + + else if (grid .eq. 'M01') then ! SMAP 1 km grid + CELL_km = 1.00001118863 ! nominal cell size in kilometers + cols = 34668 + rows = 14688 + r0 = 17333.5 + s0 = 7343.5 + + else + + print *,'easeV1_convert: unknown resolution: ',grid + stop + + endif + + else + + print *, 'easeV1_convert: unknown projection: ', grid + stop + + endif + + Rg = RE_km/CELL_km + + end subroutine easeV1_get_params + + + + subroutine easeV2_convert (grid, lat, lon, col_ind, row_ind) + + ! convert geographic coordinates (spherical earth) to + ! azimuthal equal area or equal area cylindrical grid coordinates + ! + ! *** NOTE order of calling arguments: "lat-lon-lon-lat" *** + ! + ! useage: call easeV2_convert (grid, lat, lon, r, s) + ! + ! input : grid - projection name '[M][xx]' + ! where xx = approximate resolution [km] + ! ie xx = "01", "03", "09", "36" (SMAP) + ! lat, lon = geo. coords. (decimal degrees) + ! + ! output: col_ind, row_ind - column, row coordinates + ! + ! -------------------------------------------------------------------------- + + character*(*), intent(in) :: grid + real, intent(in) :: lat, lon + real, intent(out) :: col_ind, row_ind + + ! local variables + + integer :: cols, rows + real*8 :: dlon, phi, lam, map_scale_m, r0, s0, ms, x, y, sin_phi, q + + ! --------------------------------------------------------------------- + + call easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) + + dlon = lon + + if (abs(map_reference_longitude)>epsilon) then + + dlon = lon - map_reference_longitude + + end if + + if (dlon .lt. -180.0) dlon = dlon + 360.0 + if (dlon .gt. 180.0) dlon = dlon - 360.0 + + phi = lat*PI/180. ! convert from degree to radians + lam = dlon*PI/180. ! convert from degree to radians + + sin_phi = sin(phi) + + ms = map_eccentricity*sin_phi + + q = (1. - e2)* & + ( & + (sin_phi /(1. - e2*sin_phi*sin_phi)) & + - & + .5/map_eccentricity*log((1.-ms)/(1.+ms)) & + ) + + ! note: "qp" only needed for 'N' and 'S' projections + + if (grid(1:1).eq.'M') then + + x = map_equatorial_radius_m*M_kz*lam + + y = (map_equatorial_radius_m*q)/(2.*M_kz) + + else + + print *,'Polar projections not implemented yet' + stop + + endif + + row_ind = s0 - (y/map_scale_m) + col_ind = r0 + (x/map_scale_m) + + end subroutine easeV2_convert + + ! ******************************************************************* + + subroutine easeV2_inverse (grid, r, s, lat, lon) + + ! convert azimuthal equal area or equal area cylindrical + ! grid coordinates to geographic coordinates (spherical earth) + ! + ! *** NOTE order of calling arguments: "lon-lat-lat-lon" *** + ! + ! useage: call easeV1_inverse (grid, r, s, lat, lon) + ! + ! input : grid - projection name '[M][xx]' + ! where xx = approximate resolution [km] + ! ie xx = "01", "03", "09", "36" (SMAP) + ! r, s - column, row coordinates + ! + ! output: lat, lon = geo. coords. (decimal degrees) + ! + ! -------------------------------------------------------------------------- + + character*(*), intent(in) :: grid + real, intent(in) :: r, s + real, intent(out) :: lat, lon + + ! local variables + + integer :: cols, rows + real*8 :: phi, lam, map_scale_m, r0, s0, beta, x, y, qp + + ! --------------------------------------------------------------------- + + call easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) + + x = (r - r0)*map_scale_m + y = -(s - s0)*map_scale_m + + qp = (1. - e2)* & + ( & + (1./(1.-e2)) & + - & + .5/map_eccentricity*log((1.-map_eccentricity)/(1.+map_eccentricity)) & + ) + + if (grid(1:1).eq.'M') then + + beta = asin(2.*y*M_kz/(map_equatorial_radius_m*qp)) + + lam = x/(map_equatorial_radius_m*M_kz) + + else + + print *,'Polar projections not implemented yet' + stop + + endif + + phi = beta & + + ( ( e2/3. + 31./180.*e4 + 517./ 5040.*e6 )*sin(2.*beta) ) & + + ( ( 23./360.*e4 + 251./ 3780.*e6 )*sin(4.*beta) ) & + + ( ( 761./45360.*e6 )*sin(6.*beta) ) + + lat = phi*180./PI ! convert from radians to degree + lon = lam*180./PI + map_reference_longitude ! convert from radians to degree + + if (lon .lt. -180.0) lon = lon + 360.0 + if (lon .gt. 180.0) lon = lon - 360.0 + + end subroutine easeV2_inverse + + ! ******************************************************************* + + subroutine easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) + + implicit none + + character*(*), intent(in) :: grid + real*8, intent(out) :: map_scale_m, r0, s0 + integer, intent(out) :: cols, rows + + + if (grid(1:1).eq.'M') then + + if (grid .eq. 'M36') then ! SMAP 36 km grid + + map_scale_m = 36032.220840584 ! nominal cell size in meters + cols = 964 + rows = 406 + r0 = (cols-1)/2.0 + s0 = (rows-1)/2.0 + + + else if (grid .eq. 'M25') then ! 25 km grid + + map_scale_m = 25025.2600000 ! nominal cell size in meters (see doi:10.3390/ijgi3031154) + cols = 1388 + rows = 584 + r0 = (cols-1)/2.0 + s0 = (rows-1)/2 + + else if (grid .eq. 'M09') then ! SMAP 9 km grid + + map_scale_m = 9008.055210146 ! nominal cell size in meters + cols = 3856 + rows = 1624 + r0 = (cols-1)/2.0 + s0 = (rows-1)/2.0 + + else if (grid .eq. 'M03') then ! SMAP 3 km grid + + map_scale_m = 3002.6850700487 ! nominal cell size in meters + cols = 11568 + rows = 4872 + r0 = (cols-1)/2.0 + s0 = (rows-1)/2.0 + + else if (grid .eq. 'M01') then ! SMAP 1 km grid + + map_scale_m = 1000.89502334956 ! nominal cell size in meters + cols = 34704 + rows = 14616 + r0 = (cols-1)/2.0 + s0 = (rows-1)/2.0 + + else + + print *,'easeV2_convert: unknown resolution: ',grid + stop + + endif + + else if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) then + + print *,'Polar projections not implemented yet' + stop + + else + + print *, 'easeV2_convert: unknown projection: ', grid + stop + + endif + + end subroutine easeV2_get_params + + ! ******************************************************************* + + subroutine easeV2_extent( grid, N_cols, N_rows ) + + ! simple wrapper to get N_cols (N_lon) and N_rows (N_lat) + + implicit none + + character*(*), intent(in) :: grid + integer, intent(out) :: N_cols, N_rows + + ! local variables + + real*8 :: map_scale_m, r0, s0 + + ! ------------------------------------------------ + + call easeV2_get_params( grid, map_scale_m, N_cols, N_rows, r0, s0 ) + + end subroutine easeV2_extent + + ! ******************************************************************* + +end module EASE_conv + +! =============================== EOF ================================= + diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/easeV1_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/easeV1_conv.F90 deleted file mode 100644 index 859c467a1..000000000 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/easeV1_conv.F90 +++ /dev/null @@ -1,305 +0,0 @@ - -module easeV1_conv - - ! ========================================================================== - ! - ! easeV1_conv.F90 - FORTRAN routines for conversion of azimuthal - ! equal area and equal area cylindrical grid coordinates - ! - ! 30-Jan-1992 H.Maybee - ! 20-Mar-1992 Ken Knowles 303-492-0644 knowles@kryos.colorado.edu - ! 16-Dec-1993 MJ Brodzik 303-492-8263 brodzik@jokull.colorado.edu - ! Copied from nsmconv.f, changed resolutions from - ! 40-20-10 km to 25-12.5 km - ! 21-Dec-1993 MJ Brodzik 303-492-8263 brodzik@jokull.colorado.edu - ! Fixed sign of Southern latitudes in ease_inverse. - ! 12-Sep-1994 David Hoogstrate 303-492-4116 hoogstra@jokull.colorado.edu - ! Changed grid cell size. Changed "c","f" to "l","h" - ! 25-Oct-1994 David Hoogstrate 303-492-4116 hoogstra@jokull.colorado.edu - ! Changed row size from 587 to 586 for Mercator projection - ! 11-May-2011 reichle: Changed "smap" to "easeV1". - ! Added SSM/I and AMSR-E "M25" grid. - ! So far ONLY for cylindrical grids. - ! Converted from *.f to *.F90 module - ! - ! $Log$ - ! Revision 1.1.4.2 2012/04/18 18:04:57 smahanam - ! updated on 4-18-2012 to process global data on native grids and time steps - ! - ! Revision 1.1.2.1 2012-01-27 20:22:10 smahanam - ! Added Richard's equation solver, replaced SMAP f77 files with F90 module - ! - ! Revision 1.1 2011-05-11 21:58:46 rreichle - ! - ! Adding utilities to map between EASE grids and lat/lon coordinates. - ! - ! Revision 1.3 1994/11/01 23:40:43 brodzik - ! Replaced all references to 'ease' with 'smap' - ! Replaced all references to 'smap' with 'easeV1' -- reichle - ! - ! ========================================================================== - - implicit none - - private - - public :: easeV1_convert - public :: easeV1_inverse - - - ! ***NEVER*** change these constants to GEOS-5 MAPL constants!!!! - - ! radius of the earth (km), authalic sphere based on International datum - - real*8, parameter :: RE_km = 6371.228 - - ! scale factor for standard paralles at +/-30.00 degrees - - real*8, parameter :: COS_PHI1 = .866025403 - - real*8, parameter :: PI = 3.141592653589793 - - -contains - - ! ******************************************************************* - - subroutine easeV1_convert (grid, lat, lon, r, s) - - ! convert geographic coordinates (spherical earth) to - ! azimuthal equal area or equal area cylindrical grid coordinates - ! - ! status = easeV1_convert (grid, lat, lon, r, s) - ! - ! input : grid - projection name '[M][xx]' - ! where xx = approximate resolution [km] - ! ie xx = "01", "03", "09", "36" (SMAP) - ! or xx = "12", "25" (SSM/I, AMSR-E) - ! lat, lon = geo. coords. (decimal degrees) - ! - ! output: r, s - column, row coordinates - ! - ! result: status = 0 indicates normal successful completion - ! -1 indicates error status (point not on grid) - ! - ! -------------------------------------------------------------------------- - - character*(*), intent(in) :: grid - real, intent(in) :: lat, lon - real, intent(out) :: r, s - - ! local variables - - integer :: cols, rows, scale - real*8 :: Rg, phi, lam, rho, CELL_km, r0, s0 - - ! --------------------------------------------------------------------- - - call easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) - - phi = lat*PI/180. ! convert from degree to radians - lam = lon*PI/180. ! convert from degree to radians - - if (grid(1:1).eq.'N') then - rho = 2 * Rg * sin(PI/4. - phi/2.) - r = r0 + rho * sin(lam) - s = s0 + rho * cos(lam) - - else if (grid(1:1).eq.'S') then - rho = 2 * Rg * cos(PI/4. - phi/2.) - r = r0 + rho * sin(lam) - s = s0 - rho * cos(lam) - - else if (grid(1:1).eq.'M') then - r = r0 + Rg * lam * COS_PHI1 - s = s0 - Rg * sin(phi) / COS_PHI1 - - endif - - end subroutine easeV1_convert - - ! ******************************************************************* - - subroutine easeV1_inverse (grid, r, s, lat, lon) - - ! convert azimuthal equal area or equal area cylindrical - ! grid coordinates to geographic coordinates (spherical earth) - ! - ! status = easeV1_inverse (grid, r, s, lat, lon) - ! - ! input : grid - projection name '[M][xx]' - ! where xx = approximate resolution [km] - ! ie xx = "01", "03", "09", "36" (SMAP) - ! or xx = "12", "25" (SSM/I, AMSR-E) - ! r, s - column, row coordinates - ! - ! output: lat, lon = geo. coords. (decimal degrees) - ! - ! result: status = 0 indicates normal successful completion - ! -1 indicates error status (point not on grid) - ! - ! -------------------------------------------------------------------------- - - character*(*), intent(in) :: grid - real, intent(in) :: r, s - real, intent(out) :: lat, lon - - ! local variables - - integer :: cols, rows, scale - real*8 :: Rg, phi, lam, rho, CELL_km, r0, s0 - real*8 :: gamma, beta, epsilon, x, y, c - real*8 :: sinphi1, cosphi1 - - ! --------------------------------------------------------------------- - - call easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) - - x = r - r0 - y = -(s - s0) - - if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) then - rho = sqrt(x*x + y*y) - if (rho.eq.0.0) then - if (grid(1:1).eq.'N') lat = 90.0 - if (grid(1:1).eq.'S') lat = -90.0 - lon = 0.0 - else - if (grid(1:1).eq.'N') then - sinphi1 = sin(PI/2.) - cosphi1 = cos(PI/2.) - if (y.eq.0.) then - if (r.le.r0) lam = -PI/2. - if (r.gt.r0) lam = PI/2. - else - lam = atan2(x,-y) - endif - else if (grid(1:1).eq.'S') then - sinphi1 = sin(-PI/2.) - cosphi1 = cos(-PI/2.) - if (y.eq.0.) then - if (r.le.r0) lam = -PI/2. - if (r.gt.r0) lam = PI/2. - else - lam = atan2(x,y) - endif - endif - gamma = rho/(2 * Rg) - if (abs(gamma) .gt. 1.) return - c = 2 * asin(gamma) - beta = cos(c) * sinphi1 + y * sin(c) * (cosphi1/rho) - if (abs(beta).gt.1.) return - phi = asin(beta) - lat = phi*180./PI ! convert from radians to degree - lon = lam*180./PI ! convert from radians to degree - endif - - else if (grid(1:1).eq.'M') then - - ! allow .5 cell tolerance in arcsin function - ! so that grid coordinates which are less than .5 cells - ! above 90.00N or below 90.00S are given a lat of 90.00 - - epsilon = 1 + 0.5/Rg - beta = y*COS_PHI1/Rg - if (abs(beta).gt.epsilon) return - if (beta.le.-1.) then - phi = -PI/2. - else if (beta.ge.1.) then - phi = PI/2. - else - phi = asin(beta) - endif - lam = x/COS_PHI1/Rg - lat = phi*180./PI ! convert from radians to degree - lon = lam*180./PI ! convert from radians to degree - endif - - end subroutine easeV1_inverse - - ! ******************************************************************* - - subroutine easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) - - implicit none - - character*(*), intent(in) :: grid - real*8, intent(out) :: CELL_km, r0, s0, Rg - integer, intent(out) :: cols, rows - - ! -------------------------------------------------------- - ! - ! r0,s0 are defined such that cells at all scales have - ! coincident center points - ! - !c r0 = (cols-1)/2. * scale - !c s0 = (rows-1)/2. * scale - ! - ! -------------------------------------------------------- - - if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) then - - print *,'Polar projections not implemented yet' - stop - - else if (grid(1:1).eq.'M') then - - if (grid .eq. 'M36') then ! SMAP 36 km grid - CELL_km = 36.00040279063 ! nominal cell size in kilometers - cols = 963 - rows = 408 - r0 = 481.0 - s0 = 203.5 - - else if (grid .eq. 'M25') then ! SSM/I, AMSR-E 25 km grid - CELL_km = 25.067525 ! nominal cell size in kilometers - cols = 1383 - rows = 586 - r0 = 691.0 - s0 = 292.5 - - else if (grid .eq. 'M09') then ! SMAP 9 km grid - CELL_km = 9.00010069766 ! nominal cell size in kilometers - cols = 3852 - rows = 1632 - r0 = 1925.5 - s0 = 815.5 - - else if (grid .eq. 'M03') then ! SMAP 3 km grid - CELL_km = 3.00003356589 ! nominal cell size in kilometers - cols = 11556 - rows = 4896 - r0 = 5777.5 - s0 = 2447.5 - - else if (grid .eq. 'M01') then ! SMAP 1 km grid - CELL_km = 1.00001118863 ! nominal cell size in kilometers - cols = 34668 - rows = 14688 - r0 = 17333.5 - s0 = 7343.5 - - else - - print *,'easeV1_convert: unknown resolution: ',grid - stop - - endif - - else - - print *, 'easeV1_convert: unknown projection: ', grid - stop - - endif - - Rg = RE_km/CELL_km - - end subroutine easeV1_get_params - - ! ******************************************************************* - -end module easeV1_conv - -! =============================== EOF ================================= - diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/easeV2_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/easeV2_conv.F90 deleted file mode 100644 index 5b7370e6b..000000000 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/easeV2_conv.F90 +++ /dev/null @@ -1,317 +0,0 @@ - -module easeV2_conv - - ! ========================================================================== - ! - ! easeV2_conv.F90 - FORTRAN routines for converting grid coordinates - ! (latitude/longitude <--> row/column indices) - ! of the Equal Area Scalable Earth, version 2 (EASEv2) grid - ! - ! ***** ONLY cylindrical ('M') projection implemented ***** - ! - ! Ported from Steven Chan's matlab code (smapease2inverse.m, - ! smapease2forward.m), which has been ported from NSIDC's IDL code - ! (wgs84_convert.pro, wgs84_inverse.pro) available from - ! ftp://sidads.colorado.edu/pub/tools/easegrid/geolocation_tools/ - ! - ! Official references: - ! doi:10.3390/ijgi1010032 - ! doi:10.3390/ijgi3031154 -- correction of M25 "map_scale_m" parameters! - ! - ! 04-Apr-2013 - reichle - ! 11-Sep-2018 - reichle, mgirotto -- added 'M25' grid parameters - ! - ! ========================================================================== - - implicit none - - private - - public :: easeV2_convert - public :: easeV2_inverse - public :: easeV2_extent - - ! ***NEVER*** change these constants to GEOS-5 MAPL constants!!!! - - ! radius of the earth (m) and map eccentricity - - real*8, parameter :: map_equatorial_radius_m = 6378137.0 - - real*8, parameter :: map_eccentricity = 0.081819190843 - - real*8, parameter :: PI = 3.14159265358979323846 - - real*8, parameter :: e2 = map_eccentricity * map_eccentricity - real*8, parameter :: e4 = e2 * e2 - real*8, parameter :: e6 = e2 * e4 - - real*8, parameter :: epsilon = 1.e-6 - - real*8, parameter :: map_reference_longitude = 0.0 ! 'M', 'N', 'S' - - ! constants for 'N' and 'S' (azimuthal) projections - - real*8, parameter :: N_map_reference_latitude = 90.0 - real*8, parameter :: S_map_reference_latitude = -90.0 - - ! constants for 'M' (cylindrical) projection - - real*8, parameter :: M_map_reference_latitude = 0.0 - real*8, parameter :: M_map_second_reference_latitude = 30.0 - - real*8, parameter :: M_sin_phi1 = sin(M_map_second_reference_latitude*PI/180.) - real*8, parameter :: M_cos_phi1 = cos(M_map_second_reference_latitude*PI/180.) - - real*8, parameter :: M_kz = M_cos_phi1/sqrt(1.0-e2*M_sin_phi1*M_sin_phi1) - - -contains - - ! ******************************************************************* - - subroutine easeV2_convert (grid, lat, lon, col_ind, row_ind) - - ! convert geographic coordinates (spherical earth) to - ! azimuthal equal area or equal area cylindrical grid coordinates - ! - ! *** NOTE order of calling arguments: "lat-lon-lon-lat" *** - ! - ! useage: call easeV2_convert (grid, lat, lon, r, s) - ! - ! input : grid - projection name '[M][xx]' - ! where xx = approximate resolution [km] - ! ie xx = "01", "03", "09", "36" (SMAP) - ! lat, lon = geo. coords. (decimal degrees) - ! - ! output: col_ind, row_ind - column, row coordinates - ! - ! -------------------------------------------------------------------------- - - character*(*), intent(in) :: grid - real, intent(in) :: lat, lon - real, intent(out) :: col_ind, row_ind - - ! local variables - - integer :: cols, rows - real*8 :: dlon, phi, lam, map_scale_m, r0, s0, ms, x, y, sin_phi, q - - ! --------------------------------------------------------------------- - - call easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) - - dlon = lon - - if (abs(map_reference_longitude)>epsilon) then - - dlon = lon - map_reference_longitude - - end if - - if (dlon .lt. -180.0) dlon = dlon + 360.0 - if (dlon .gt. 180.0) dlon = dlon - 360.0 - - phi = lat*PI/180. ! convert from degree to radians - lam = dlon*PI/180. ! convert from degree to radians - - sin_phi = sin(phi) - - ms = map_eccentricity*sin_phi - - q = (1. - e2)* & - ( & - (sin_phi /(1. - e2*sin_phi*sin_phi)) & - - & - .5/map_eccentricity*log((1.-ms)/(1.+ms)) & - ) - - ! note: "qp" only needed for 'N' and 'S' projections - - if (grid(1:1).eq.'M') then - - x = map_equatorial_radius_m*M_kz*lam - - y = (map_equatorial_radius_m*q)/(2.*M_kz) - - else - - print *,'Polar projections not implemented yet' - stop - - endif - - row_ind = s0 - (y/map_scale_m) - col_ind = r0 + (x/map_scale_m) - - end subroutine easeV2_convert - - ! ******************************************************************* - - subroutine easeV2_inverse (grid, r, s, lat, lon) - - ! convert azimuthal equal area or equal area cylindrical - ! grid coordinates to geographic coordinates (spherical earth) - ! - ! *** NOTE order of calling arguments: "lon-lat-lat-lon" *** - ! - ! useage: call easeV1_inverse (grid, r, s, lat, lon) - ! - ! input : grid - projection name '[M][xx]' - ! where xx = approximate resolution [km] - ! ie xx = "01", "03", "09", "36" (SMAP) - ! r, s - column, row coordinates - ! - ! output: lat, lon = geo. coords. (decimal degrees) - ! - ! -------------------------------------------------------------------------- - - character*(*), intent(in) :: grid - real, intent(in) :: r, s - real, intent(out) :: lat, lon - - ! local variables - - integer :: cols, rows - real*8 :: phi, lam, map_scale_m, r0, s0, beta, x, y, qp - - ! --------------------------------------------------------------------- - - call easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) - - x = (r - r0)*map_scale_m - y = -(s - s0)*map_scale_m - - qp = (1. - e2)* & - ( & - (1./(1.-e2)) & - - & - .5/map_eccentricity*log((1.-map_eccentricity)/(1.+map_eccentricity)) & - ) - - if (grid(1:1).eq.'M') then - - beta = asin(2.*y*M_kz/(map_equatorial_radius_m*qp)) - - lam = x/(map_equatorial_radius_m*M_kz) - - else - - print *,'Polar projections not implemented yet' - stop - - endif - - phi = beta & - + ( ( e2/3. + 31./180.*e4 + 517./ 5040.*e6 )*sin(2.*beta) ) & - + ( ( 23./360.*e4 + 251./ 3780.*e6 )*sin(4.*beta) ) & - + ( ( 761./45360.*e6 )*sin(6.*beta) ) - - lat = phi*180./PI ! convert from radians to degree - lon = lam*180./PI + map_reference_longitude ! convert from radians to degree - - if (lon .lt. -180.0) lon = lon + 360.0 - if (lon .gt. 180.0) lon = lon - 360.0 - - end subroutine easeV2_inverse - - ! ******************************************************************* - - subroutine easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) - - implicit none - - character*(*), intent(in) :: grid - real*8, intent(out) :: map_scale_m, r0, s0 - integer, intent(out) :: cols, rows - - - if (grid(1:1).eq.'M') then - - if (grid .eq. 'M36') then ! SMAP 36 km grid - - map_scale_m = 36032.220840584 ! nominal cell size in meters - cols = 964 - rows = 406 - r0 = (cols-1)/2.0 - s0 = (rows-1)/2.0 - - else if (grid .eq. 'M25') then ! 25 km grid - - map_scale_m = 25025.2600000 ! nominal cell size in meters (see doi:10.3390/ijgi3031154) - cols = 1388 - rows = 584 - r0 = (cols-1)/2.0 - s0 = (rows-1)/2.0 - - else if (grid .eq. 'M09') then ! SMAP 9 km grid - - map_scale_m = 9008.055210146 ! nominal cell size in meters - cols = 3856 - rows = 1624 - r0 = (cols-1)/2.0 - s0 = (rows-1)/2.0 - - else if (grid .eq. 'M03') then ! SMAP 3 km grid - - map_scale_m = 3002.6850700487 ! nominal cell size in meters - cols = 11568 - rows = 4872 - r0 = (cols-1)/2.0 - s0 = (rows-1)/2.0 - - else if (grid .eq. 'M01') then ! SMAP 1 km grid - - map_scale_m = 1000.89502334956 ! nominal cell size in meters - cols = 34704 - rows = 14616 - r0 = (cols-1)/2.0 - s0 = (rows-1)/2.0 - - else - - print *,'easeV2_convert: unknown resolution: ',grid - stop - - endif - - else if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) then - - print *,'Polar projections not implemented yet' - stop - - else - - print *, 'easeV2_convert: unknown projection: ', grid - stop - - endif - - end subroutine easeV2_get_params - - ! ******************************************************************* - - subroutine easeV2_extent( grid, N_cols, N_rows ) - - ! simple wrapper to get N_cols (N_lon) and N_rows (N_lat) - - implicit none - - character*(*), intent(in) :: grid - integer, intent(out) :: N_cols, N_rows - - ! local variables - - real*8 :: map_scale_m, r0, s0 - - ! ------------------------------------------------ - - call easeV2_get_params( grid, map_scale_m, N_cols, N_rows, r0, s0 ) - - end subroutine easeV2_extent - - ! ******************************************************************* - -end module easeV2_conv - -! =============================== EOF ================================= - diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara.F90 index fc62e7718..7c938574d 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara.F90 @@ -5,7 +5,7 @@ PROGRAM mkSMAPTilesPara_v1 ! f90 -c smapconv.f ! f90 -o create_smap_tiles create_smap_tiles.o smapconv.o ! - use easeV1_conv + use EASE_conv use rmTinyCatchParaMod use process_hres_data use MAPL_SortMod diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index 55c1abc37..520c91d32 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -8,7 +8,7 @@ PROGRAM mkSMAPTilesPara_v2 ! f90 -c smapconv.f ! f90 -o create_smap_tiles create_smap_tiles.o smapconv.o ! - use easeV2_conv + use EASE_conv use rmTinyCatchParaMod use process_hres_data use MAPL_SortMod @@ -65,19 +65,21 @@ PROGRAM mkSMAPTilesPara_v2 character*128 :: MaskFile logical :: pfaf_til = .false. character*1 :: PF - + character(len=2) :: EASE_Version + include 'netcdf.inc' N_args = command_argument_count() if(N_args < 1) then - print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX' - print *,'Allowed SMAP grids are: M01 M03 M09 M25 M36' + print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -v LBCSV -pfaf_til x -ease_version xx' + print *,'Allowed SMAP grids are: M01 M03 M09 M25 M36' + print *,'Allowed EASE_VERSION are: v1 v2' stop end if + EASE_Version = 'v2' i=0 - do while ( i < N_args ) i = i+1 @@ -96,77 +98,92 @@ PROGRAM mkSMAPTilesPara_v2 elseif ( trim(arg) == '-v' ) then i = i+1 call get_command_argument(i,LBCSV) + + elseif ( trim(arg) == '-ease_version' ) then + i = i+1 + call get_command_argument(i,EASE_Version) else ! stop for any other arguments - print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -pfaf_til T' + print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -pfaf_til T -v LBCSV -ease_version xx' print *,'Allowed SMAP grids are: M09 M36 Ml' stop endif end do + + if (MGRID /= 'M25' .and. EASE_version == 'v1') then + stop ("EASEv1 only supports M25") + endif - call execute_command_line('cd data/ ; ln -s /discover/nobackup/projects/gmao/ssd/land/l_data/LandBCs_files_for_mkCatchParam/V001/ CATCH') - call execute_command_line('cd ..') - + ! WY noted: should do it in the script that calls this program + !call execute_command_line('cd data/ ; ln -s /discover/nobackup/projects/gmao/ssd/land/l_data/LandBCs_files_for_mkCatchParam/V001/ CATCH') + !call execute_command_line('cd ..') ! Setting SMAP Grid specifications ! -------------------------------- - + + EASElabel = 'SMAP_EASEv2_'//trim(MGRID) + if (ease_version == 'v1') EASElabel = 'SMAP_EASE_M25' + if (trim(MGRID) == 'M09') then - + CELL_km = 9.008055210146 ! nominal cell size in kilometers nc_smap = 3856 nr_smap = 1624 - gfile = 'SMAP_EASEv2_'//trim(MGRID)//'_3856x1624' EASE_grid_area = CELL_km*CELL_km - EASElabel = 'SMAP-EASEv2-M09' - + gfile = trim(EASElabel)//'_3856x1624' + elseif(trim(MGRID) == 'M36') then - + CELL_km = 36.032220840584 ! nominal cell size in kilometers nc_smap = 964 nr_smap = 406 - gfile = 'SMAP_EASEv2_'//trim(MGRID)//'_964x406' EASE_grid_area = CELL_km*CELL_km - EASElabel = 'SMAP-EASEv2-M36' - - elseif(trim(MGRID) == 'M25') then - - CELL_km = 25.0252600081 ! nominal cell size in kilometers - nc_smap = 1388 - nr_smap = 584 - gfile = 'SMAP_EASEv2_M25_1388x584' + gfile = trim(EASElabel)//'_964x406' + + elseif(trim(MGRID) == 'M25') then + + if (ease_version == 'v2') then + CELL_km = 25.0252600081 ! nominal cell size in kilometers + nc_smap = 1388 + nr_smap = 584 + gfile = trim(EASElabel)//'_1388x584' + else if (ease_version == 'v1') then + CELL_km = 25.067525 ! nominal cell size in kilometers + nc_smap = 1383 + nr_smap = 586 + gfile = trim(EASElabel)//'_1383x586' + endif EASE_grid_area = CELL_km*CELL_km - + else if (trim(MGRID) .eq. 'M03') then ! SMAP 3 km grid CELL_km = 3.0026850700487 ! nominal cell size in kilometers nc_smap = 11568 nr_smap = 4872 - gfile = 'SMAP_EASEv2_M03_11568x4872' EASE_grid_area = CELL_km*CELL_km regrid = .true. NC = 21600 NR = 10800 NT = 500000000 - + gfile = trim(EASElabel)//'_11568x4872' + else if (trim(MGRID) .eq. 'M01') then ! SMAP 1 km grid CELL_km = 1.00089502334956 ! nominal cell size in kilometers nc_smap = 34704 nr_smap = 14616 - gfile = 'SMAP_EASEv2_M01_34704x14616' EASE_grid_area = CELL_km*CELL_km regrid = .true. NC = 43200 - NR = 21600 + NR = 21600 NT = 1500000000 - + gfile = trim(EASElabel)//'_34704x14616' else ! - + print *,'Unknown SMAP Grid stopping..' stop - + endif allocate(land_id (1:NT)) @@ -306,7 +323,7 @@ PROGRAM mkSMAPTilesPara_v2 ! count in if this is i,j pixel is a land, lake or ice within ind_col,ind_row SMAP grid cell - call easeV2_convert(trim(MGRID), clat, clon, r_smap, s_smap) + call EASE_convert(EASELabel, clat, clon, r_smap, s_smap) ind_col = nint(r_smap) + 1 ind_row = nint(s_smap) + 1 @@ -462,7 +479,7 @@ PROGRAM mkSMAPTilesPara_v2 do j =nr ,1 ,-1 clat = -90. + float(j-1)*dy + dy/2. - call easeV2_convert(trim(MGRID), clat, clon, r_smap, s_smap) + call EASE_convert(EASELabel, clat, clon, r_smap, s_smap) ind_col = nint(r_smap) + 1 ind_row = nint(s_smap) + 1 @@ -554,7 +571,7 @@ PROGRAM mkSMAPTilesPara_v2 do j =nr ,1 ,-1 lats = -90._8 + (j - 0.5_8)*dy clat = -90. + float(j-1)*dy + dy/2. - call easeV2_convert(trim(MGRID), clat, clon, r_smap, s_smap) + call EASE_convert(EASELabel, clat, clon, r_smap, s_smap) ind_col = nint(r_smap) + 1 ind_row = nint(s_smap) + 1 @@ -669,7 +686,7 @@ PROGRAM mkSMAPTilesPara_v2 open (10, file ='til/'//trim(gfile)//'.til',form='formatted',status='unknown',action='write') write (10,*)i_index,SRTM_maxcat, nc, nr write (10,*)1 - write (10,*)'SMAP-EASEv2-'//trim(MGRID) + write (10,*)EASELabel write (10,*)nc_smap write (10,*)nr_smap ! write (10,*)'NO-OCEAN' @@ -694,20 +711,20 @@ PROGRAM mkSMAPTilesPara_v2 if (l <= l_index) then typ = 100 - call easeV2_inverse (trim(MGRID), real(ig-1),real(jg-1), clat, clon) + call EASE_inverse (EASELabel, real(ig-1),real(jg-1), clat, clon) mnx = clon - 180./real(nc_smap) mxx = clon + 180./real(nc_smap) jgv = real(jg-1) + 0.5 - call easeV2_inverse (trim(MGRID), real(ig-1),jgv, clat, clon) + call EASE_inverse (EASELabel, real(ig-1),jgv, clat, clon) mny = clat jgv = real(jg-1) - 0.5 - call easeV2_inverse (trim(MGRID), real(ig-1),jgv, clat, clon) + call EASE_inverse (EASELabel, real(ig-1),jgv, clat, clon) mxy = clat @@ -715,7 +732,7 @@ PROGRAM mkSMAPTilesPara_v2 endif - call easeV2_inverse (trim(MGRID), real(ig-1), real(jg-1), clat, clon) + call EASE_inverse (EASELabel, real(ig-1), real(jg-1), clat, clon) fr_gcm= tile_area(l)/smap_grid_area(jg*ND + ig) @@ -779,7 +796,7 @@ SUBROUTINE mkEASEv2Raster do i = 1, nc_smap+1 x = real(i-1) -0.5 y = real(nr_smap - j)+0.5 - call easeV2_inverse(MGRID, x, y, yout, xout) + call EASE_inverse(MGRID, x, y, yout, xout) ys (i,j) = dble(yout) xs (i,j) = dble(xout) end do From 82631b3521e51145346a2c6918391e11498909d5 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 9 Sep 2022 11:03:49 -0400 Subject: [PATCH 16/77] change netcdf interface to nf90 --- .../Utils/Raster/mkSMAPTilesPara_v2.F90 | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index 520c91d32..00b6da8a6 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -14,6 +14,7 @@ PROGRAM mkSMAPTilesPara_v2 use MAPL_SortMod use MAPL_ConstantsMod use LogRectRasterizeMod + use netcdf implicit none character*5 :: LBCSV = 'UNDEF' @@ -35,6 +36,7 @@ PROGRAM mkSMAPTilesPara_v2 integer :: dx_esa, dy_esa, NBINS, NPLUS integer*8, allocatable, dimension (:) :: SRTM_catid + real(kind=8),allocatable, dimension(:):: SRTM_catid_r8 integer,allocatable, dimension (:,:), target :: tileid_index,catid_index integer,allocatable, dimension (:,:) :: catid, iaster @@ -51,7 +53,7 @@ PROGRAM mkSMAPTilesPara_v2 character(3) :: easegrid real :: clat, clon, r_smap, s_smap, smap_convert, da real :: fr_gcm - integer :: ind_col, ind_row, status, ncid, nciv,nland_cells, DOM_INDX + integer :: ind_col, ind_row, status, ncid, varid, nciv,nland_cells, DOM_INDX REAL (kind=8), PARAMETER :: RADIUS=6378137.0,pi=3.14159265358979323846 character*100 :: veg_class (12) character*5 :: MGRID @@ -67,8 +69,6 @@ PROGRAM mkSMAPTilesPara_v2 character*1 :: PF character(len=2) :: EASE_Version - include 'netcdf.inc' - N_args = command_argument_count() if(N_args < 1) then @@ -230,6 +230,7 @@ PROGRAM mkSMAPTilesPara_v2 allocate(tileid_index(1:nc,1:nr)) allocate(SRTM_catid (1:SRTM_maxcat+2)) + allocate(SRTM_catid_r8(1:SRTM_maxcat+2), source = 0.d0) allocate(catid_index (1:nc,1:nr)) allocate(veg (1:nc,1:nr)) allocate(geos_msk (1:nc_esa,1:dy_esa)) @@ -255,25 +256,26 @@ PROGRAM mkSMAPTilesPara_v2 catid_index = 0 veg = 0 - status = NF_OPEN ('data/CATCH/GEOS5_10arcsec_mask.nc', NF_NOWRITE, ncid) - status = NF_GET_VARA_INT64 (ncid,3,(/1/),(/SRTM_maxcat/),SRTM_catid(1:SRTM_maxcat)) ! Read pfafstetter IDs + status = NF90_OPEN ('data/CATCH/GEOS5_10arcsec_mask.nc', NF90_NOWRITE, ncid) + status = nf90_inq_varid(ncid, name='PfafID', varid=varid) + status = nf90_get_var(ncid, varid, SRTM_catid_r8, (/1/),(/SRTM_maxcat/)) if(status /=0) then - PRINT *, NF_STRERROR(STATUS) - print *, 'Problem with NF_OPEN',trim(MaskFile) + PRINT *, NF90_STRERROR(STATUS) + print *, 'Problem with NF90_OPEN',trim(MaskFile) endif - + SRTM_catid = int8(SRTM_catid_r8) SRTM_catid (SRTM_maxcat + 1) = 190000000 SRTM_catid (SRTM_maxcat + 2) = 200000000 i1 = 0 ! count # of 30-arcsec pixels - + status = nf90_inq_varid(ncid, name='CatchIndex', varid=varid) do j=1,nr clat = -90. + float(j-1)*dy + dy/2. - - status = NF_GET_VARA_INT (ncid,4,(/1,(j-1)*dy_esa +1/),(/nc_esa,dy_esa/),geos_msk) ! Read 10-arcsec rows that lie within the raster row 'j' + status = NF90_GET_VAR (ncid, varid, geos_msk, (/1,(j-1)*dy_esa +1/),(/nc_esa,dy_esa/)) ! Read 10-arcsec rows that lie within the raster row 'j' + !status = NF_GET_VARA_INT (ncid,4,(/1,(j-1)*dy_esa +1/),(/nc_esa,dy_esa/),geos_msk) ! Read 10-arcsec rows that lie within the raster row 'j' if(status /=0) then - PRINT *, NF_STRERROR(STATUS) + PRINT *, NF90_STRERROR(STATUS) print *, 'Problem with NF_GET_VARA_INT',trim(MaskFile),status endif @@ -343,7 +345,7 @@ PROGRAM mkSMAPTilesPara_v2 end do enddo - status = NF_CLOSE (ncid) + status = NF90_CLOSE (ncid) deallocate (geos_msk) print *,'Read ', trim (MaskFile) @@ -758,7 +760,7 @@ PROGRAM mkSMAPTilesPara_v2 !--------------------------------------------------- - deallocate (SRTM_CatchArea, SRTM_catid) + deallocate (SRTM_CatchArea, SRTM_catid, SRTM_catid_r8) endif From 2a9fcd9037540b36873f6d0e101f167fdd2fd728 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Mon, 12 Sep 2022 08:00:23 -0400 Subject: [PATCH 17/77] move mkCatchParam.x run out of mkSMAPTilePara_v2.x --- .../Utils/Raster/make_bcs | 41 ++++++++----------- .../Utils/Raster/mkSMAPTilesPara_v2.F90 | 28 +++++++------ 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index f4fe05525..f47495fe1 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -1317,35 +1317,30 @@ cd data ln -s $input_dir CATCH cd ../ limit stacksize unlimited + if ( $EVERSION == EASEv2 ) then -setenv MASKFILE ${MASKFILE} -## This section was used to make Irrigated Tiles -##if(${MGRID} == M09 | ${MGRID} == M36) then -## bin/mkLandRaster.x -x ${NX} -y ${NY} -v -t ${NT} -## bin/mkSMAPTilesPara_v2.x -smap_grid ${MGRID} -pfaf_til T -## bin/CombineRasters.x -f 0 -t 232000000 ${THISGRID} Pfafstetter > /dev/null -## bin/CombineRasters.x -t 232000000 ${THISGRID} ${THISGRID}-Pfafstetter -## /bin/mv til/${THISGRID}_${THISGRID}-Pfafstetter.til til/${THISGRID}_${THISGRID}-Pfafstetter.ind -##endif -setenv OMP_NUM_THREADS 1 -bin/mkSMAPTilesPara_v2.x -smap_grid ${MGRID} -v $lbcsv -setenv OMP_NUM_THREADS ${NCPUS} -head -1 clsm/mkCatchParam.log > smap_cmd -chmod 755 smap_cmd -./smap_cmd -chmod 755 bin/create_README.csh -bin/create_README.csh -else + ## This section was used to make Irrigated Tiles + ##if(${MGRID} == M09 | ${MGRID} == M36) then + ## bin/mkLandRaster.x -x ${NX} -y ${NY} -v -t ${NT} + ## bin/mkSMAPTilesPara_v2.x -smap_grid ${MGRID} -pfaf_til T + ## bin/CombineRasters.x -f 0 -t 232000000 ${THISGRID} Pfafstetter > /dev/null + ## bin/CombineRasters.x -t 232000000 ${THISGRID} ${THISGRID}-Pfafstetter + ## /bin/mv til/${THISGRID}_${THISGRID}-Pfafstetter.til til/${THISGRID}_${THISGRID}-Pfafstetter.ind + ##endif +endif +if ( $EVERSION == EASE ) then + ## for easev1, default values + set lbcsv = UNDEF +endif + setenv MASKFILE ${MASKFILE} setenv OMP_NUM_THREADS 1 -bin/mkSMAPTilesPara.x -smap_grid ${MGRID} +# WY NOTE: the name mkSMAPTilesPara_v2.x will be changed to bin/bin/mkSMAPTilesPara.x +bin/mkSMAPTilesPara_v2.x -smap_grid ${MGRID} -v $lbcsv -ease_version $EVERSION setenv OMP_NUM_THREADS ${NCPUS} -head -1 clsm/mkCatchParam.log > smap_cmd -chmod 755 smap_cmd -./smap_cmd +bin/mkCatchParam.x -e EASE -g ${BCNAME} -v $lbcsv -x ${NX} -y ${NY} chmod 755 bin/create_README.csh bin/create_README.csh -endif /bin/mv clsm clsm.${IM}x${JM} /bin/cp til/SMAP_${EVERSION}_${MGRID}_${RS}.til clsm.${IM}x${JM} diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index 00b6da8a6..9d202c56f 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -67,18 +67,18 @@ PROGRAM mkSMAPTilesPara_v2 character*128 :: MaskFile logical :: pfaf_til = .false. character*1 :: PF - character(len=2) :: EASE_Version + character(len=6) :: EASE_Version N_args = command_argument_count() if(N_args < 1) then print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -v LBCSV -pfaf_til x -ease_version xx' print *,'Allowed SMAP grids are: M01 M03 M09 M25 M36' - print *,'Allowed EASE_VERSION are: v1 v2' + print *,'Allowed EASE_VERSION are: EASE EASEv2' stop end if - EASE_Version = 'v2' + EASE_Version = 'EASEv2' i=0 do while ( i < N_args ) @@ -113,7 +113,7 @@ PROGRAM mkSMAPTilesPara_v2 end do - if (MGRID /= 'M25' .and. EASE_version == 'v1') then + if (MGRID /= 'M25' .and. trim(EASE_version) == 'EASE') then stop ("EASEv1 only supports M25") endif @@ -124,8 +124,7 @@ PROGRAM mkSMAPTilesPara_v2 ! Setting SMAP Grid specifications ! -------------------------------- - EASElabel = 'SMAP_EASEv2_'//trim(MGRID) - if (ease_version == 'v1') EASElabel = 'SMAP_EASE_M25' + EASElabel = 'SMAP_'//trim(ease_version)//'_'//trim(MGRID) if (trim(MGRID) == 'M09') then @@ -145,12 +144,12 @@ PROGRAM mkSMAPTilesPara_v2 elseif(trim(MGRID) == 'M25') then - if (ease_version == 'v2') then + if (ease_version == 'EASEv2') then CELL_km = 25.0252600081 ! nominal cell size in kilometers nc_smap = 1388 nr_smap = 584 gfile = trim(EASElabel)//'_1388x584' - else if (ease_version == 'v1') then + else CELL_km = 25.067525 ! nominal cell size in kilometers nc_smap = 1383 nr_smap = 586 @@ -772,12 +771,15 @@ PROGRAM mkSMAPTilesPara_v2 ! now run mkCatchParam ! -------------------- - tmpstring1 = '-e EASE -g '//trim(gfile)//' -v '//trim(LBCSV) - write(tmpstring2,'(2(a2,x,i5,x))')'-x',nc,'-y',nr - tmpstring = 'bin/mkCatchParam.x '//trim(tmpstring2)//' '//trim(tmpstring1) - print *,trim(tmpstring) + ! WY Note: now mkCatchParam is run in the make_bcs script, not here + ! and nthread will be reset to run mkCatchParam + + ! tmpstring1 = '-e EASE -g '//trim(gfile)//' -v '//trim(LBCSV) + ! write(tmpstring2,'(2(a2,x,i5,x))')'-x',nc,'-y',nr + ! tmpstring = 'bin/mkCatchParam.x '//trim(tmpstring2)//' '//trim(tmpstring1) + ! print *,trim(tmpstring) - call execute_command_line (tmpstring) + ! call execute_command_line (tmpstring) contains From b8c939b047ffacfc4ac474b64d625912f09401b2 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Wed, 14 Sep 2022 12:51:09 -0400 Subject: [PATCH 18/77] use different PIs for easeV1 and easeV2 for zero-diff bcs --- .../Utils/Raster/EASE_conv.F90 | 134 ++++++++++-------- 1 file changed, 74 insertions(+), 60 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 index d41501faf..d028e4a14 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 @@ -1,7 +1,19 @@ module EASE_conv - ! ========================================================================== + ! ===================================================================================== + ! + ! EASE_conv.F90 - FORTRAN routines for conversion of Equal-Area Scalable Earth (EASE) + ! grid coordinates (lat/lon <--> row/col indices) + ! + ! Implemented for global cylindrical ('Mxx') EASE grids only. + ! + ! Works for EASE[v1] and EASEv2 grids. + ! + ! ------------------------------------------------------------------------------------- + ! + ! CHANGELOG (easeV1_conv.F90): + ! ============================ ! ! easeV1_conv.F90 - FORTRAN routines for conversion of azimuthal ! equal area and equal area cylindrical grid coordinates @@ -23,59 +35,16 @@ module EASE_conv ! Converted from *.f to *.F90 module ! ! $Log$ - ! Revision 1.1.2.3 2018/09/13 20:42:50 wjiang - ! change M25 - ! - ! Revision 1.1.2.2 2017/09/18 15:10:25 wjiang - ! "fix" strange compiler erro on comment line. - ! - ! Revision 1.1.2.1 2017/01/19 19:35:58 wjiang - ! 1)add EASE grid support - ! 2)add ensemble average for HISTORY - ! - ! Revision 1.2 2014-08-26 17:33:55 rreichle - ! - clean-up of *.F90 in GEOSlana_GridComp: - ! - make sure all modules include "private" statement - ! - follow all "use" statements with "ONLY" - ! - removed unused files (esat_qsat.F90, nr_sort.f) - ! - removed unused variables - ! ! Revision 1.1 2011-05-11 21:58:46 rreichle - ! ! Adding utilities to map between EASE grids and lat/lon coordinates. ! ! Revision 1.3 1994/11/01 23:40:43 brodzik ! Replaced all references to 'ease' with 'smap' ! Replaced all references to 'smap' with 'easeV1' -- reichle - ! - ! ========================================================================== - - implicit none - - private - - public :: ease_convert - public :: ease_inverse -! public :: easeV1_convert -! public :: easeV1_inverse -! public :: easeV2_convert -! public :: easeV2_inverse -! public :: easeV2_extent - - - ! ***NEVER*** change these constants to GEOS-5 MAPL constants!!!! - - ! radius of the earth (km), authalic sphere based on International datum - - real*8, parameter :: RE_km = 6371.228 - - ! scale factor for standard paralles at +/-30.00 degrees - - real*8, parameter :: COS_PHI1 = .866025403 - - real*8, parameter :: PI = 3.14159265358979323846 - - ! ========================================================================== + ! + ! + ! CHANGELOG (easeV2_conv.F90): + ! ============================ ! ! easeV2_conv.F90 - FORTRAN routines for converting grid coordinates ! (latitude/longitude <--> row/column indices) @@ -88,8 +57,6 @@ module EASE_conv ! (wgs84_convert.pro, wgs84_inverse.pro) available from ! ftp://sidads.colorado.edu/pub/tools/easegrid/geolocation_tools/ ! - ! 04-Apr-2013 - reichle - ! ! Official references: ! doi:10.3390/ijgi1010032 ! doi:10.3390/ijgi3031154 -- correction of M25 "map_scale_m" parameters! @@ -97,10 +64,44 @@ module EASE_conv ! 04-Apr-2013 - reichle ! 11-Sep-2018 - reichle, mgirotto -- added 'M25' grid parameters ! + ! + ! CHANGELOG (EASE_conv.F90): + ! ========================== + ! + ! 2022-09-13, wjiang+reichle: + ! merged easeV1_conv.F90 and easeV2_conv.F90 into EASE_conv.F90 + ! + ! ! ========================================================================== + implicit none + + private + + public :: ease_convert + public :: ease_inverse + + ! ======================================================================= + ! + ! EASEv1 global constants + + ! ***NEVER*** change these constants to GEOS MAPL constants!!!! + + ! radius of the earth (km), authalic sphere based on International datum + + real*8, parameter :: easeV1_RE_km = 6371.228 + + ! scale factor for standard paralles at +/-30.00 degrees + + real*8, parameter :: easeV1_COS_PHI1 = .866025403 + + real*8, parameter :: easeV1_PI = 3.141592653589793 + + ! ======================================================================= + ! + ! EASEv2 global constants - ! ***NEVER*** change these constants to GEOS-5 MAPL constants!!!! + ! ***NEVER*** change these constants to GEOS MAPL constants!!!! ! radius of the earth (m) and map eccentricity @@ -108,6 +109,7 @@ module EASE_conv real*8, parameter :: map_eccentricity = 0.081819190843 + real*8, parameter :: easeV2_PI = 3.14159265358979323846 real*8, parameter :: e2 = map_eccentricity * map_eccentricity real*8, parameter :: e4 = e2 * e2 @@ -127,14 +129,16 @@ module EASE_conv real*8, parameter :: M_map_reference_latitude = 0.0 real*8, parameter :: M_map_second_reference_latitude = 30.0 - real*8, parameter :: M_sin_phi1 = sin(M_map_second_reference_latitude*PI/180.) - real*8, parameter :: M_cos_phi1 = cos(M_map_second_reference_latitude*PI/180.) + real*8, parameter :: M_sin_phi1 = sin(M_map_second_reference_latitude*easeV2_PI/180.) + real*8, parameter :: M_cos_phi1 = cos(M_map_second_reference_latitude*easeV2_PI/180.) real*8, parameter :: M_kz = M_cos_phi1/sqrt(1.0-e2*M_sin_phi1*M_sin_phi1) contains + ! ******************************************************************* + subroutine ease_convert (gridname, lat, lon, r, s) character*(*), intent(in) :: gridname real, intent(in) :: lat, lon @@ -162,6 +166,8 @@ subroutine ease_convert (gridname, lat, lon, r, s) endif end subroutine + ! ******************************************************************* + subroutine ease_inverse (gridname, r, s, lat, lon) character*(*), intent(in) :: gridname real, intent(in) :: r, s @@ -220,6 +226,8 @@ subroutine easeV1_convert (grid, lat, lon, r, s) integer :: cols, rows real*8 :: Rg, phi, lam, rho, CELL_km, r0, s0 + real*8, parameter :: PI = easeV1_PI + ! --------------------------------------------------------------------- call easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) @@ -238,8 +246,8 @@ subroutine easeV1_convert (grid, lat, lon, r, s) s = s0 - rho * cos(lam) else if (grid(1:1).eq.'M') then - r = r0 + Rg * lam * COS_PHI1 - s = s0 - Rg * sin(phi) / COS_PHI1 + r = r0 + Rg * lam * easeV1_COS_PHI1 + s = s0 - Rg * sin(phi) / easeV1_COS_PHI1 endif @@ -278,6 +286,8 @@ subroutine easeV1_inverse (grid, r, s, lat, lon) real*8 :: gamma, beta, epsilon, x, y, c real*8 :: sinphi1, cosphi1 + real*8, parameter :: PI = easeV1_PI + ! --------------------------------------------------------------------- call easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) @@ -328,7 +338,7 @@ subroutine easeV1_inverse (grid, r, s, lat, lon) ! above 90.00N or below 90.00S are given a lat of 90.00 epsilon = 1 + 0.5/Rg - beta = y*COS_PHI1/Rg + beta = y*easeV1_COS_PHI1/Rg if (abs(beta).gt.epsilon) return if (beta.le.-1.) then phi = -PI/2. @@ -337,7 +347,7 @@ subroutine easeV1_inverse (grid, r, s, lat, lon) else phi = asin(beta) endif - lam = x/COS_PHI1/Rg + lam = x/easeV1_COS_PHI1/Rg lat = phi*180./PI ! convert from radians to degree lon = lam*180./PI ! convert from radians to degree endif @@ -420,11 +430,11 @@ subroutine easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) endif - Rg = RE_km/CELL_km + Rg = easeV1_RE_km/CELL_km end subroutine easeV1_get_params - + ! ******************************************************************* subroutine easeV2_convert (grid, lat, lon, col_ind, row_ind) @@ -453,6 +463,8 @@ subroutine easeV2_convert (grid, lat, lon, col_ind, row_ind) integer :: cols, rows real*8 :: dlon, phi, lam, map_scale_m, r0, s0, ms, x, y, sin_phi, q + real*8, parameter :: PI = easeV2_PI + ! --------------------------------------------------------------------- call easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) @@ -531,6 +543,8 @@ subroutine easeV2_inverse (grid, r, s, lat, lon) integer :: cols, rows real*8 :: phi, lam, map_scale_m, r0, s0, beta, x, y, qp + real*8, parameter :: PI = easeV2_PI + ! --------------------------------------------------------------------- call easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) @@ -599,7 +613,7 @@ subroutine easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) cols = 1388 rows = 584 r0 = (cols-1)/2.0 - s0 = (rows-1)/2 + s0 = (rows-1)/2.0 else if (grid .eq. 'M09') then ! SMAP 9 km grid From 24d874850a32c50b10c3d5df36f2455a82d69dcd Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 16 Sep 2022 09:17:50 -0400 Subject: [PATCH 19/77] add ease_get_params for cleanup --- .../Utils/Raster/EASE_conv.F90 | 40 ++- .../Utils/Raster/make_bcs | 69 +++-- .../Utils/Raster/mkSMAPTilesPara_v2.F90 | 261 ++++++++---------- 3 files changed, 188 insertions(+), 182 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 index d028e4a14..8b94ca8c1 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 @@ -80,6 +80,7 @@ module EASE_conv public :: ease_convert public :: ease_inverse + public :: ease_get_params ! ======================================================================= ! @@ -159,7 +160,7 @@ subroutine ease_convert (gridname, lat, lon, r, s) if(index(gridname,'EASEv2') /=0) then call easeV2_convert(grid,lat,lon,r,s) - else if(index(gridname,'EASE') /=0) then + else if(index(gridname,'EASEv1') /=0) then call easeV1_convert(grid,lat,lon,r,s) else print*,"wrong gridname: "//gridname @@ -188,13 +189,48 @@ subroutine ease_inverse (gridname, r, s, lat, lon) if(index(gridname,'EASEv2') /=0) then call easeV2_inverse(grid,r,s,lat,lon) - else if(index(gridname,'EASE') /=0) then + else if(index(gridname,'EASEv1') /=0) then call easeV1_inverse(grid,r,s,lat,lon) else print*,"wrong gridname: "//gridname endif end subroutine ease_inverse + subroutine ease_get_params (gridname, CELL_km, cols, rows, r0, s0, Rg ) + implicit none + character*(*), intent(in) :: gridname + real*8, intent(out) :: CELL_km + integer, intent(out) :: cols, rows + real*8, intent(out) :: r0, s0, Rg + + real*8 :: map_scale_m + character(3) :: grid + + if (index(gridname,'M36') /=0 ) then + grid='M36' + else if (index(gridname,'M25') /=0 ) then + grid='M25' + else if (index(gridname,'M09') /=0 ) then + grid='M09' + else if (index(gridname,'M03') /=0 ) then + grid='M03' + else if (index(gridname,'M01') /=0 ) then + grid='M01' + endif + + if(index(gridname,'EASEv2') /=0) then + call easeV2_get_params(grid, map_scale_m, cols, rows, r0, s0) + Rg = -9999.0 + CELL_km = map_scale_m/1000.d0 + else if(index(gridname,'EASEv1') /=0) then + call easeV1_get_params(grid, CELL_km, cols, rows, r0, s0, Rg) + else + print*,"wrong gridname: "//gridname + endif + + end subroutine ease_get_params + + ! ******************************************************************* ! ******************************************************************* subroutine easeV1_convert (grid, lat, lon, r, s) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index f47495fe1..c70c66f9b 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -935,7 +935,6 @@ ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM6/1440x1080 data/M cd data ln -s $input_dir CATCH - cd ../ if( -e CF${NC}x6C_${DATENAME}${IMO}x${POLENAME}${JMO}.stdout ) /bin/rm -f CF${NC}x6C_${DATENAME}${IMO}x${POLENAME}${JMO}.stdout @@ -1261,41 +1260,41 @@ endif # End Cube Test ####################################################################### if( $grid == ease ) then -echo $HRCODE - -if( $HRCODE == m25 ) then -set EVERSION = EASE -else -set EVERSION = EASEv2 -endif - -set RS = ${im}x${jm} -set IM = `echo ${im} | awk '{printf "%4.4i", $1}'` -set JM = `echo ${jm} | awk '{printf "%4.4i", $1}'` - -set BCNAME = SMAP_${EVERSION}_${MGRID} -set BCDIR = $EXPDIR/$OUTDIR/$BCNAME.scratch -set BCJOB = $BCDIR/$BCNAME.j -set THISGRID = SMAP-${EVERSION}-${MGRID} - -set nfiles = `find $EXPDIR -maxdepth 5 -name ${BCNAME}".j" | wc -l` -if( $nfiles >= 1 ) then - echo "" - echo "${C1} ----------------------------------------------------${CR}" - echo "${C1} Abort: ${CR}" - echo "${C2} This BCS run $BCDIR ${CR}" - echo "${C2} will create resolution dir already present: $BCNAME ${CR}" - echo "${C2} Please delete run dir and same resolution BCS files and resubmit" - echo "${C1} ----------------------------------------------------${CR}" - echo "" - exit -endif + echo $HRCODE + + if( $HRCODE == m25 ) then + set EVERSION = EASEv1 + else + set EVERSION = EASEv2 + endif + + set RS = ${im}x${jm} + set IM = `echo ${im} | awk '{printf "%4.4i", $1}'` + set JM = `echo ${jm} | awk '{printf "%4.4i", $1}'` + + set BCNAME = SMAP_${EVERSION}_${MGRID} + set BCDIR = $EXPDIR/$OUTDIR/$BCNAME.scratch + set BCJOB = $BCDIR/$BCNAME.j + set THISGRID = SMAP-${EVERSION}-${MGRID} + + set nfiles = `find $EXPDIR -maxdepth 5 -name ${BCNAME}".j" | wc -l` + if( $nfiles >= 1 ) then + echo "" + echo "${C1} ----------------------------------------------------${CR}" + echo "${C1} Abort: ${CR}" + echo "${C2} This BCS run $BCDIR ${CR}" + echo "${C2} will create resolution dir already present: $BCNAME ${CR}" + echo "${C2} Please delete run dir and same resolution BCS files and resubmit" + echo "${C1} ----------------------------------------------------${CR}" + echo "" + exit + endif -mkdir -p $BCDIR -mkdir -p $EXPDIR/$OUTDIR/logs + mkdir -p $BCDIR + mkdir -p $EXPDIR/$OUTDIR/logs -echo "${C1} Creating:${CR} ${C2}$BCJOB${CR}" -/bin/rm -f $BCJOB + echo "${C1} Creating:${CR} ${C2}$BCJOB${CR}" + /bin/rm -f $BCJOB cat << _EOF_ > $BCJOB #!/bin/csh -x @@ -1328,7 +1327,7 @@ if ( $EVERSION == EASEv2 ) then ## /bin/mv til/${THISGRID}_${THISGRID}-Pfafstetter.til til/${THISGRID}_${THISGRID}-Pfafstetter.ind ##endif endif -if ( $EVERSION == EASE ) then +if ( $EVERSION == EASEv1 ) then ## for easev1, default values set lbcsv = UNDEF endif diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index 9d202c56f..5ad047920 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -59,7 +59,7 @@ PROGRAM mkSMAPTilesPara_v2 character*5 :: MGRID character*100 :: gfile,gtopo30 integer :: nc_smap,nr_smap, N_args, command_argument_count - real :: EASE_grid_area, CELL_km + real*8 :: CELL_km REAL :: dx,dy,d2r,lats,mnx,mxx,mny,mxy,sum1,sum2,jgv, VDUM,pix_area character(40) :: arg, EASElabel character*200 :: tmpstring, tmpstring1, tmpstring2 @@ -68,17 +68,18 @@ PROGRAM mkSMAPTilesPara_v2 logical :: pfaf_til = .false. character*1 :: PF character(len=6) :: EASE_Version - + real*8 :: r0, s0, Rg + character(len=10) :: nc_string, nr_string + N_args = command_argument_count() if(N_args < 1) then - print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -v LBCSV -pfaf_til x -ease_version xx' + print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -v LBCSV -ease_version xx' print *,'Allowed SMAP grids are: M01 M03 M09 M25 M36' - print *,'Allowed EASE_VERSION are: EASE EASEv2' + print *,'Allowed EASE_VERSION are: EASEv1 EASEv2' stop end if - EASE_Version = 'EASEv2' i=0 do while ( i < N_args ) @@ -90,10 +91,11 @@ PROGRAM mkSMAPTilesPara_v2 i = i+1 call get_command_argument(i,MGRID) - elseif ( trim(arg) == '-pfaf_til' ) then - i = i+1 - call get_command_argument(i,PF) - if (PF == 'T') pfaf_til = .true. + ! WY noted: this may be used in the future for irrigation tiles + !elseif ( trim(arg) == '-pfaf_til' ) then + ! i = i+1 + ! call get_command_argument(i,PF) + ! if (PF == 'T') pfaf_til = .true. elseif ( trim(arg) == '-v' ) then i = i+1 @@ -104,16 +106,15 @@ PROGRAM mkSMAPTilesPara_v2 call get_command_argument(i,EASE_Version) else ! stop for any other arguments - - print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -pfaf_til T -v LBCSV -ease_version xx' - print *,'Allowed SMAP grids are: M09 M36 Ml' + print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -v LBCSV -ease_version xx' + print *,'Allowed SMAP grids are: M01, M03, M09, M25, M36 ' + print *,'Allowed ease_version are: EASEv1 EASEv2' stop - endif end do - if (MGRID /= 'M25' .and. trim(EASE_version) == 'EASE') then + if (MGRID /= 'M25' .and. EASE_version == 'EASEv1') then stop ("EASEv1 only supports M25") endif @@ -124,65 +125,30 @@ PROGRAM mkSMAPTilesPara_v2 ! Setting SMAP Grid specifications ! -------------------------------- - EASElabel = 'SMAP_'//trim(ease_version)//'_'//trim(MGRID) - - if (trim(MGRID) == 'M09') then + EASElabel = 'SMAP_'//ease_version//'_'//trim(MGRID) - CELL_km = 9.008055210146 ! nominal cell size in kilometers - nc_smap = 3856 - nr_smap = 1624 - EASE_grid_area = CELL_km*CELL_km - gfile = trim(EASElabel)//'_3856x1624' + call ease_get_params(EASELabel, CELL_km, nc_smap, nr_smap, r0,s0, Rg) + write(nc_string, '(i0)') nc_smap + write(nr_string, '(i0)') nr_smap + gfile = trim(EASElabel)//'_'//trim(nc_string)//'x'//trim(nc_string) - elseif(trim(MGRID) == 'M36') then - - CELL_km = 36.032220840584 ! nominal cell size in kilometers - nc_smap = 964 - nr_smap = 406 - EASE_grid_area = CELL_km*CELL_km - gfile = trim(EASElabel)//'_964x406' - - elseif(trim(MGRID) == 'M25') then - - if (ease_version == 'EASEv2') then - CELL_km = 25.0252600081 ! nominal cell size in kilometers - nc_smap = 1388 - nr_smap = 584 - gfile = trim(EASElabel)//'_1388x584' - else - CELL_km = 25.067525 ! nominal cell size in kilometers - nc_smap = 1383 - nr_smap = 586 - gfile = trim(EASElabel)//'_1383x586' - endif - EASE_grid_area = CELL_km*CELL_km - - else if (trim(MGRID) .eq. 'M03') then ! SMAP 3 km grid - CELL_km = 3.0026850700487 ! nominal cell size in kilometers - nc_smap = 11568 - nr_smap = 4872 - EASE_grid_area = CELL_km*CELL_km + if (trim(MGRID) .eq. 'M03') then ! SMAP 3 km grid regrid = .true. NC = 21600 NR = 10800 NT = 500000000 - gfile = trim(EASElabel)//'_11568x4872' - - else if (trim(MGRID) .eq. 'M01') then ! SMAP 1 km grid - CELL_km = 1.00089502334956 ! nominal cell size in kilometers - nc_smap = 34704 - nr_smap = 14616 - EASE_grid_area = CELL_km*CELL_km + endif + if (trim(MGRID) .eq. 'M01') then ! SMAP 1 km grid regrid = .true. NC = 43200 NR = 21600 NT = 1500000000 - gfile = trim(EASElabel)//'_34704x14616' - else ! - - print *,'Unknown SMAP Grid stopping..' - stop - + endif + ! + if ( .not. (trim(MGRID) .eq. 'M01' .or. trim(MGRID) .eq. 'M03' .or. & + trim(MGRID) .eq. 'M09' .or. trim(MGRID) .eq. 'M25' .or. & + trim(MGRID) .eq. 'M36')) then + stop('Unknown SMAP Grid stopping..') endif allocate(land_id (1:NT)) @@ -204,16 +170,16 @@ PROGRAM mkSMAPTilesPara_v2 print *, 'Using MaskFile ', trim(MaskFile) - if(pfaf_til) then + ! This section was used to make Irrigated Tiles + !if(pfaf_til) then - nc = 43200 ! Number of rows in raster file - nr = 21600 - call mkEASEv2Raster + ! nc = 43200 ! Number of rows in raster file + ! nr = 21600 + ! call mkEASEv2Raster !else - ! This section was used to make Irrigated Tiles ! if((trim(MGRID) == 'M09').or.(trim(MGRID) == 'M36'))call write_tilfile - endif + !endif if (index(MaskFile,'GEOS5_10arcsec_mask') /= 0) then ! New ESA (Veg) + SRTM (catchments) based mask file @@ -781,82 +747,87 @@ PROGRAM mkSMAPTilesPara_v2 ! call execute_command_line (tmpstring) - contains - - ! ------------------------------------------------------------------------------- - - SUBROUTINE mkEASEv2Raster - - implicit none - - integer :: i, j, i_ease, j_ease - real*8, allocatable :: xs(:,:), ys(:,:) - real :: x,y, xout, yout - - allocate (xs ( nc_smap+1, nr_smap+1)) - allocate (ys ( nc_smap+1, nr_smap+1)) - - do j = 1, nr_smap+1 - do i = 1, nc_smap+1 - x = real(i-1) -0.5 - y = real(nr_smap - j)+0.5 - call EASE_inverse(MGRID, x, y, yout, xout) - ys (i,j) = dble(yout) - xs (i,j) = dble(xout) - end do - end do - - call LRRasterize(EASElabel,xs,ys,nc=nc,nr=nr,xmn = xs(1,1), xmx= xs(nc_smap+1, nr_smap+1), ymn=ys(1,1), ymx = ys(nc_smap+1, nr_smap+1), Here=.false., Verb=.false.) - - stop - end SUBROUTINE mkEASEv2Raster - ! ------------------------------------------------------------ - - SUBROUTINE write_tilfile - - implicit none - - character*200 :: infile - integer :: NT, NF, NC, NR, NPF, NG, IDUM, i, N, icol, rcol - character*20 :: cdum - integer, dimension (:,:), allocatable :: iRtable - real, dimension (:,:), allocatable :: rRtable - - infile = 'til/'//trim(EASElabel)//'_'//trim(EASElabel)//'-Pfafstetter.' - - open (10,file = trim(infile)//'ind', form = 'formatted', action = 'read', status = 'old') - open (11,file = trim(infile)//'TIL', form = 'formatted', action = 'write', status = 'unknown') - - read (10, *) NT, NF, NC, NR - write (11,'(4I10)')NT, NF, NC, NR - read (10, *) NG - write(11, *) NG - - do n = 1, NG - read (10, '(a)') cdum - write(11, '(a)') trim (cdum) - read (10, *) IDUM - write(11, '(I10)') IDUM - read (10, *) IDUM - write(11, '(I10)') IDUM - end do - - icol = 7 - rcol = 5 - allocate (iRtable (1, 1:icol)) - allocate (rRtable (1, 1:rcol)) - - do n = 1, nt - read(10,'(I10,3E20.12,9(2I10,E20.12,I10))') iRtable (1,1),rRtable(1,1),rRtable(1,2),rRtable(1,3),iRtable (1,2),iRtable (1,3),rRtable(1,4),iRtable (1,4),& - iRtable (1,5),iRtable (1,6),rRtable(1,5),iRtable (1,7) - write(11,'(I10,3E20.12,9(2I10,E20.12,I10))') iRtable (1,1),rRtable(1,1),rRtable(1,2),rRtable(1,3),iRtable (1,2)-1,nr_smap - iRtable (1,3),rRtable(1,4),iRtable (1,4),& - iRtable (1,5),iRtable (1,6),rRtable(1,5),iRtable (1,7) - end do - - close (10, status = 'keep') - close (11, status = 'keep') - - END SUBROUTINE write_tilfile +!!! commented out. It may be used in the future for irrigation tiles +!!! contains +!!! +!!! ! ------------------------------------------------------------------------------- +!!! +!!! SUBROUTINE mkEASEv2Raster +!!! +!!! implicit none +!!! +!!! integer :: i, j, i_ease, j_ease +!!! real*8, allocatable :: xs(:,:), ys(:,:) +!!! real :: x,y, xout, yout +!!! +!!! allocate (xs ( nc_smap+1, nr_smap+1)) +!!! allocate (ys ( nc_smap+1, nr_smap+1)) +!!! +!!! do j = 1, nr_smap+1 +!!! do i = 1, nc_smap+1 +!!! x = real(i-1) -0.5 +!!! y = real(nr_smap - j)+0.5 +!!! call EASE_inverse(MGRID, x, y, yout, xout) +!!! ys (i,j) = dble(yout) +!!! xs (i,j) = dble(xout) +!!! end do +!!! end do +!!! +!!! call LRRasterize(EASElabel,xs,ys,nc=nc,nr=nr,xmn = xs(1,1), xmx= xs(nc_smap+1, nr_smap+1), & +!!! ymn=ys(1,1), ymx = ys(nc_smap+1, nr_smap+1), Here=.false., Verb=.false.) +!!! +!!! stop +!!! end SUBROUTINE mkEASEv2Raster +!!! +!!! ! ------------------------------------------------------------ +!!! +!!! SUBROUTINE write_tilfile +!!! +!!! implicit none +!!! +!!! character*200 :: infile +!!! integer :: NT, NF, NC, NR, NPF, NG, IDUM, i, N, icol, rcol +!!! character*20 :: cdum +!!! integer, dimension (:,:), allocatable :: iRtable +!!! real, dimension (:,:), allocatable :: rRtable +!!! +!!! infile = 'til/'//trim(EASElabel)//'_'//trim(EASElabel)//'-Pfafstetter.' +!!! +!!! open (10,file = trim(infile)//'ind', form = 'formatted', action = 'read', status = 'old') +!!! open (11,file = trim(infile)//'TIL', form = 'formatted', action = 'write', status = 'unknown') +!!! +!!! read (10, *) NT, NF, NC, NR +!!! write (11,'(4I10)')NT, NF, NC, NR +!!! read (10, *) NG +!!! write(11, *) NG +!!! +!!! do n = 1, NG +!!! read (10, '(a)') cdum +!!! write(11, '(a)') trim (cdum) +!!! read (10, *) IDUM +!!! write(11, '(I10)') IDUM +!!! read (10, *) IDUM +!!! write(11, '(I10)') IDUM +!!! end do +!!! +!!! icol = 7 +!!! rcol = 5 +!!! allocate (iRtable (1, 1:icol)) +!!! allocate (rRtable (1, 1:rcol)) +!!! +!!! do n = 1, nt +!!! read(10,'(I10,3E20.12,9(2I10,E20.12,I10))') iRtable (1,1),rRtable(1,1), & +!!! rRtable(1,2),rRtable(1,3),iRtable (1,2),iRtable (1,3),rRtable(1,4),iRtable (1,4),& +!!! iRtable (1,5),iRtable (1,6),rRtable(1,5),iRtable (1,7) +!!! write(11,'(I10,3E20.12,9(2I10,E20.12,I10))') iRtable (1,1),rRtable(1,1), & +!!! rRtable(1,2),rRtable(1,3),iRtable (1,2)-1,nr_smap - iRtable (1,3),rRtable(1,4),iRtable (1,4),& +!!! iRtable (1,5),iRtable (1,6),rRtable(1,5),iRtable (1,7) +!!! end do +!!! +!!! close (10, status = 'keep') +!!! close (11, status = 'keep') +!!! +!!! END SUBROUTINE write_tilfile END PROGRAM From 0ec8f4a4b3494da7d79d874fd47332a7b4f27fa9 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 16 Sep 2022 09:35:01 -0400 Subject: [PATCH 20/77] pass EASElable --- .../Utils/Raster/make_bcs | 2 +- .../Utils/Raster/mkSMAPTilesPara_v2.F90 | 39 +++++++++---------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index c70c66f9b..c0d31273f 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -1335,7 +1335,7 @@ endif setenv MASKFILE ${MASKFILE} setenv OMP_NUM_THREADS 1 # WY NOTE: the name mkSMAPTilesPara_v2.x will be changed to bin/bin/mkSMAPTilesPara.x -bin/mkSMAPTilesPara_v2.x -smap_grid ${MGRID} -v $lbcsv -ease_version $EVERSION +bin/mkSMAPTilesPara_v2.x -smap_grid ${BCNAME} -v $lbcsv setenv OMP_NUM_THREADS ${NCPUS} bin/mkCatchParam.x -e EASE -g ${BCNAME} -v $lbcsv -x ${NX} -y ${NY} chmod 755 bin/create_README.csh diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index 5ad047920..c5e5cb2ab 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -2,7 +2,7 @@ PROGRAM mkSMAPTilesPara_v2 -! This program constructs land and lake tiles for the SMAP-EASE-M09 and M36 grids (just set MGRID) +! This program constructs land and lake tiles for the SMAP_EASEv1_Mxx ! for CLSM implementation. ! f90 -c create_smap_tiles.f90 ! f90 -c smapconv.f @@ -56,12 +56,12 @@ PROGRAM mkSMAPTilesPara_v2 integer :: ind_col, ind_row, status, ncid, varid, nciv,nland_cells, DOM_INDX REAL (kind=8), PARAMETER :: RADIUS=6378137.0,pi=3.14159265358979323846 character*100 :: veg_class (12) - character*5 :: MGRID character*100 :: gfile,gtopo30 integer :: nc_smap,nr_smap, N_args, command_argument_count real*8 :: CELL_km REAL :: dx,dy,d2r,lats,mnx,mxx,mny,mxy,sum1,sum2,jgv, VDUM,pix_area - character(40) :: arg, EASElabel + character(40) :: arg, EASElabel_ + character(len=:), allocatable :: EASElabel character*200 :: tmpstring, tmpstring1, tmpstring2 logical :: regrid = .false. character*128 :: MaskFile @@ -74,9 +74,9 @@ PROGRAM mkSMAPTilesPara_v2 N_args = command_argument_count() if(N_args < 1) then - print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -v LBCSV -ease_version xx' - print *,'Allowed SMAP grids are: M01 M03 M09 M25 M36' - print *,'Allowed EASE_VERSION are: EASEv1 EASEv2' + print *,'USAGE : bin/mkSMAPTiles -smap_grid EASELabel -v LBCSV' + print *,'Allowed SMAP grids are: SMAP_EASEv1_M01 M03 M09 M25 M36' + print *,'Allowed SMAP grids are: SMAP_EASEv2_M01 M03 M09 M25 M36' stop end if @@ -89,7 +89,7 @@ PROGRAM mkSMAPTilesPara_v2 if ( trim(arg) == '-smap_grid' ) then i = i+1 - call get_command_argument(i,MGRID) + call get_command_argument(i,EASELabel_) ! WY noted: this may be used in the future for irrigation tiles !elseif ( trim(arg) == '-pfaf_til' ) then @@ -101,10 +101,6 @@ PROGRAM mkSMAPTilesPara_v2 i = i+1 call get_command_argument(i,LBCSV) - elseif ( trim(arg) == '-ease_version' ) then - i = i+1 - call get_command_argument(i,EASE_Version) - else ! stop for any other arguments print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -v LBCSV -ease_version xx' print *,'Allowed SMAP grids are: M01, M03, M09, M25, M36 ' @@ -113,10 +109,11 @@ PROGRAM mkSMAPTilesPara_v2 endif end do - - if (MGRID /= 'M25' .and. EASE_version == 'EASEv1') then - stop ("EASEv1 only supports M25") - endif + + ! WY note, remove this verification. There can be all combination + ! if (MGRID /= 'M25' .and. EASE_version == 'EASEv1') then + ! stop ("EASEv1 only supports M25") + ! endif ! WY noted: should do it in the script that calls this program !call execute_command_line('cd data/ ; ln -s /discover/nobackup/projects/gmao/ssd/land/l_data/LandBCs_files_for_mkCatchParam/V001/ CATCH') @@ -125,29 +122,29 @@ PROGRAM mkSMAPTilesPara_v2 ! Setting SMAP Grid specifications ! -------------------------------- - EASElabel = 'SMAP_'//ease_version//'_'//trim(MGRID) + EASElabel = trim(EASELabel_) call ease_get_params(EASELabel, CELL_km, nc_smap, nr_smap, r0,s0, Rg) write(nc_string, '(i0)') nc_smap write(nr_string, '(i0)') nr_smap gfile = trim(EASElabel)//'_'//trim(nc_string)//'x'//trim(nc_string) - if (trim(MGRID) .eq. 'M03') then ! SMAP 3 km grid + if (index(EASELabel,'M03') /=0) then ! SMAP 3 km grid regrid = .true. NC = 21600 NR = 10800 NT = 500000000 endif - if (trim(MGRID) .eq. 'M01') then ! SMAP 1 km grid + if (index(EASELabel,'M03') /=0) then ! SMAP 1 km grid regrid = .true. NC = 43200 NR = 21600 NT = 1500000000 endif ! - if ( .not. (trim(MGRID) .eq. 'M01' .or. trim(MGRID) .eq. 'M03' .or. & - trim(MGRID) .eq. 'M09' .or. trim(MGRID) .eq. 'M25' .or. & - trim(MGRID) .eq. 'M36')) then + if ( .not. (index(EASELabel,'M01') /=0 .or. index(EASELabel,'M03') /=0 .or. & + index(EASELabel,'M09') /=0 .or. index(EASELabel,'M25') /=0 .or. & + index(EASELabel,'M36') /=0)) then stop('Unknown SMAP Grid stopping..') endif From 0718bc8db4ee23f0187fb7669b909f117d19036f Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Fri, 16 Sep 2022 11:18:53 -0400 Subject: [PATCH 21/77] fix case options --- .../GEOSsurface_GridComp/Utils/Raster/make_bcs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index f4fe05525..ce59fa564 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -141,9 +141,9 @@ if ( $HELPMODE != YES ) then $dummy == 'NL3' | \ $dummy == 'NL4' | \ $dummy == 'NL5' | \ - $dummy == 'v06' | \ - $dummy == 'v07' | \ - $dummy == 'v08') then + $dummy == 'V06' | \ + $dummy == 'V07' | \ + $dummy == 'V08') then set lbcsv = $dummy else if ( $dummy == '' ) then echo $lbcsv From c7fb5a0f18e7d42f67f3e1f2bf7633c3b1810bb1 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Fri, 16 Sep 2022 11:21:21 -0400 Subject: [PATCH 22/77] fix MODIS collection info --- .../GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc | 2 +- .../GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 | 2 +- .../Utils/Raster/rmTinyCatchParaMod.F90 | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc index cf36809ae..3491c4f5c 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc @@ -117,7 +117,7 @@ # ---- SNOW ALBEDO # # 0 : Snow albedo parameterization based on look-up table (default) -# 1 : Snow albedo derived from MODIS Collection MOD10A1.006 (2000-2022) [NOT YET AVAILABLE FOR CatchCN] +# 1 : Snow albedo derived from MODIS Collection MOD10A1.061 (Feb/2000 - Mar/2022) [NOT YET AVAILABLE FOR CatchCN] # where available, elsewhere fall back to option 0 # # GEOSagcm=>SNOW_ALBEDO_INFO: 0 diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index 47878299e..b07b9ba3b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -192,7 +192,7 @@ PROGRAM mkCatchParam if(use_PEATMAP) PEATSOURCE = 'PEATMAP' if(jpl_height) VEGZSOURCE = 'JPL' - if (trim(SNOWALB)=='MODC006') process_snow_albedo=.true. + if (trim(SNOWALB)=='MODC061') process_snow_albedo=.true. if(n_threads == 1) then diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index e98bc7f61..992bb7310 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -85,7 +85,7 @@ SUBROUTINE init_bcs_config (LBCSV) ! ! SNOWALB: Snow albedo data. DEFAULT : LUT ! LUT : Parameterization based on look-up table values. - ! MODC006 : Static snow albedo derived from MODIS Collection 6 data where available, LUT elsewhere. + ! MODC061 : Static snow albedo derived from MODIS Collection 6.1 data where available, LUT elsewhere. ! ! SOILBCS: Soil parameter data. DEFAULT : HWSD ! HWSD : Merged HWSD-STATSGO2 soil properties on 43200x21600 with Woesten et al. (1999) parameters @@ -145,7 +145,7 @@ SUBROUTINE init_bcs_config (LBCSV) LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' - SNOWALB = 'MODC006' + SNOWALB = 'MODC061' GNU = 1.0 use_PEATMAP = .true. jpl_height = .true. @@ -163,7 +163,7 @@ SUBROUTINE init_bcs_config (LBCSV) LAIBCS = 'MODGEO' SOILBCS = 'HWSD' MODALB = 'MODIS2' - SNOWALB = 'MODC006' + SNOWALB = 'MODC061' GNU = 1.0 use_PEATMAP = .false. jpl_height = .false. From e0a5f68161e68713ddbb5766f72e415151f7dc4b Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 16 Sep 2022 11:49:29 -0400 Subject: [PATCH 23/77] add choice for EASE grid --- .../Utils/Raster/make_bcs | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index c0d31273f..0d43340f0 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -242,9 +242,28 @@ if ( $HELPMODE != YES ) then $HRCODE == 'm9' | \ $HRCODE == 'm36' | \ $HRCODE == 'm25') then - set isEASE = 1 + set isEASE = 1 endif end + + if ( $isEASE == 1 ) then + EASE_VERSION: + echo " What is the EASE grid version: EASEv1 or EASEv2 ? default is EASEv2" + set dummy = `echo $<` + + if ( $dummy == '' ) set dummy = EASEv2 + + if( $dummy == 'EASEv1' | \ + $dummy == 'EASEv2') then + set EVERSION = $dummy + echo "EASE grid Version is ${EVERSION} " + else + echo " " + echo " Invalid input, please use EASEv1 or EASEv2 " + echo " " + goto EASE_VERSION + endif + endif else @@ -1262,11 +1281,12 @@ endif # End Cube Test if( $grid == ease ) then echo $HRCODE - if( $HRCODE == m25 ) then - set EVERSION = EASEv1 - else - set EVERSION = EASEv2 - endif + #WY noted: ease version becomes input + #if( $HRCODE == m25 ) then + # set EVERSION = EASEv1 + #else + # set EVERSION = EASEv2 + #endif set RS = ${im}x${jm} set IM = `echo ${im} | awk '{printf "%4.4i", $1}'` From dd2f91a203a19c448e21922c61de8dba469a1d84 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Fri, 16 Sep 2022 12:11:49 -0400 Subject: [PATCH 24/77] better option for cases --- .../GEOSsurface_GridComp/Utils/Raster/make_bcs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index ce59fa564..2253db27f 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -133,7 +133,6 @@ if ( $HELPMODE != YES ) then set dummy = `echo $<` - set dummy = `echo $dummy | tr "[:lower:]" "[:upper:]"` if( $dummy == 'F25' | \ $dummy == 'GM4' | \ @@ -141,9 +140,9 @@ if ( $HELPMODE != YES ) then $dummy == 'NL3' | \ $dummy == 'NL4' | \ $dummy == 'NL5' | \ - $dummy == 'V06' | \ - $dummy == 'V07' | \ - $dummy == 'V08') then + $dummy == 'v06' | \ + $dummy == 'v07' | \ + $dummy == 'v08') then set lbcsv = $dummy else if ( $dummy == '' ) then echo $lbcsv From cff2c973f0665c5a411bd63c6ccfbaed3b1f86e4 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Fri, 16 Sep 2022 14:12:56 -0400 Subject: [PATCH 25/77] snowalb optional --- .../GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index 0795918ae..f02c76f6f 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -903,17 +903,6 @@ subroutine SetServices ( GC, RC ) RC=STATUS ) VERIFY_(STATUS) - call MAPL_AddInternalSpec(GC ,& - LONG_NAME = 'snow_albedo' ,& - UNITS = '1' ,& - SHORT_NAME = 'SNOWALB' ,& - FRIENDLYTO = trim(COMP_NAME) ,& - DIMS = MAPL_DimsTileOnly ,& - VLOCATION = MAPL_VLocationNone ,& - RESTART = MAPL_RestartRequired ,& - RC=STATUS ) - VERIFY_(STATUS) - call MAPL_AddInternalSpec(GC ,& LONG_NAME = 'wetness_at_wilting_point' ,& UNITS = '1' ,& @@ -1464,6 +1453,17 @@ subroutine SetServices ( GC, RC ) RC=STATUS ) VERIFY_(STATUS) + call MAPL_AddInternalSpec(GC ,& + LONG_NAME = 'snow_albedo' ,& + UNITS = '1' ,& + SHORT_NAME = 'SNOWALB' ,& + FRIENDLYTO = trim(COMP_NAME) ,& + DIMS = MAPL_DimsTileOnly ,& + VLOCATION = MAPL_VLocationNone ,& + RESTART = MAPL_RestartOptional ,& + RC=STATUS ) + VERIFY_(STATUS) + !---------- GOSWIM snow impurity related variables ---------- if (N_CONST_LAND4SNWALB /= 0) then From 5f7aba2b341e14b25e3657d1cff7b9ab36fbad2d Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 16 Sep 2022 14:21:18 -0400 Subject: [PATCH 26/77] conditional on internal variable SNOWALB --- .../GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index 0795918ae..c60a2f7f4 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -903,16 +903,6 @@ subroutine SetServices ( GC, RC ) RC=STATUS ) VERIFY_(STATUS) - call MAPL_AddInternalSpec(GC ,& - LONG_NAME = 'snow_albedo' ,& - UNITS = '1' ,& - SHORT_NAME = 'SNOWALB' ,& - FRIENDLYTO = trim(COMP_NAME) ,& - DIMS = MAPL_DimsTileOnly ,& - VLOCATION = MAPL_VLocationNone ,& - RESTART = MAPL_RestartRequired ,& - RC=STATUS ) - VERIFY_(STATUS) call MAPL_AddInternalSpec(GC ,& LONG_NAME = 'wetness_at_wilting_point' ,& @@ -1387,6 +1377,19 @@ subroutine SetServices ( GC, RC ) RC=STATUS ) VERIFY_(STATUS) + if (SNOW_ALBEDO_INFO == 1) then + call MAPL_AddInternalSpec(GC ,& + LONG_NAME = 'snow_albedo' ,& + UNITS = '1' ,& + SHORT_NAME = 'SNOWALB' ,& + FRIENDLYTO = trim(COMP_NAME) ,& + DIMS = MAPL_DimsTileOnly ,& + VLOCATION = MAPL_VLocationNone ,& + RESTART = MAPL_RestartRequired ,& + RC=STATUS ) + VERIFY_(STATUS) + endif + call MAPL_AddInternalSpec(GC ,& LONG_NAME = 'surface_heat_exchange_coefficient',& UNITS = 'kg m-2 s-1' ,& From 7f796b38509dadcb640be72d49f336beea405198 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 16 Sep 2022 14:27:18 -0400 Subject: [PATCH 27/77] typo --- .../GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index 65c84e154..53f000b18 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -1466,17 +1466,6 @@ subroutine SetServices ( GC, RC ) RC=STATUS ) VERIFY_(STATUS) - call MAPL_AddInternalSpec(GC ,& - LONG_NAME = 'snow_albedo' ,& - UNITS = '1' ,& - SHORT_NAME = 'SNOWALB' ,& - FRIENDLYTO = trim(COMP_NAME) ,& - DIMS = MAPL_DimsTileOnly ,& - VLOCATION = MAPL_VLocationNone ,& - RESTART = MAPL_RestartOptional ,& - RC=STATUS ) - VERIFY_(STATUS) - !---------- GOSWIM snow impurity related variables ---------- if (N_CONST_LAND4SNWALB /= 0) then From 0da8643eed7b861b09015341ade81b4122b6f7dd Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Mon, 19 Sep 2022 07:55:58 -0400 Subject: [PATCH 28/77] change missing value from -9999 to MAPL_UNDEF --- .../GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 1 + .../Utils/Raster/mod_process_hres_data.F90 | 7 ++++--- .../Utils/mk_restarts/CatchmentRst.F90 | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index 53f000b18..75d06bc1b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -1381,6 +1381,7 @@ subroutine SetServices ( GC, RC ) LONG_NAME = 'snow_albedo' ,& UNITS = '1' ,& SHORT_NAME = 'SNOWALB' ,& + DEFAULT = MAPL_UNDEF ,& FRIENDLYTO = trim(COMP_NAME) ,& DIMS = MAPL_DimsTileOnly ,& VLOCATION = MAPL_VLocationNone ,& diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index 92b3b161f..fda5b3424 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -26,6 +26,7 @@ MODULE process_hres_data use leap_year use MAPL_ConstantsMod use lsm_routines, ONLY: sibalb +use MAPL_Base, ONLY: MAPL_UNDEF #if defined USE_EXTERNAL_FINDLOC use findloc_mod, only: findloc @@ -3036,7 +3037,7 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) allocate (snw_alb(1:maxcat)) ! Start by setting all snow albedo values to missing - snw_alb(:)=-9999.0 + snw_alb(:)=MAPL_UNDEF do n = 1, maxcat read (10,*) tindex1,pfaf1,minlon,maxlon,minlat,maxlat @@ -3160,7 +3161,7 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) ! Calculate snow albedo for the current tile snw_alb(n) = sno_alb_sum / max(1.0,sno_alb_cnt) - if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=-9999.0 !1.E15 + if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=MAPL_UNDEF !1.E15 ! If no valid solution found, and if tile size smaller than snow albedo resolution, ! expand search area by 1-tile padding. @@ -3199,7 +3200,7 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) end do ! hhtil snw_alb(n) = sno_alb_sum2 / max(1.0,sno_alb_cnt2) - if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=-9999.0 !1.E15 + if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=MAPL_UNDEF !1.E15 endif diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index eca9d5e66..d07c0629b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -3,6 +3,7 @@ module CatchmentRstMod use mk_restarts_getidsMod use MAPL + use MAPL_Base, ONLY: MAPL_UNDEF use mpi use LSM_ROUTINES, ONLY: & catch_calc_soil_moist, & @@ -14,6 +15,7 @@ module CatchmentRstMod DZGT => CATCH_DZGT, & PEATCLSM_POROS_THRESHOLD + implicit none #ifndef __GFORTRAN__ integer :: ftell @@ -631,6 +633,7 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) var = Variable(type=pFIO_REAL32, dimensions='tile') call var%add_attribute('long_name', 'snow_albedo') call var%add_attribute('units', '1') + call var%add_attribute('_FillValue', MAPL_UNDEF) call this%meta%add_variable('SNOWALB', var) endif endif From 766dd194d5eec6a3e5366b2b98278ee2312947f0 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Mon, 19 Sep 2022 10:07:09 -0400 Subject: [PATCH 29/77] typo --- .../GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index c5e5cb2ab..19ccdb99f 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -145,7 +145,8 @@ PROGRAM mkSMAPTilesPara_v2 if ( .not. (index(EASELabel,'M01') /=0 .or. index(EASELabel,'M03') /=0 .or. & index(EASELabel,'M09') /=0 .or. index(EASELabel,'M25') /=0 .or. & index(EASELabel,'M36') /=0)) then - stop('Unknown SMAP Grid stopping..') + print*,'Unknown SMAP Grid stopping..' + stop endif allocate(land_id (1:NT)) From 58093dfd126652243584753806e442ac299e124c Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Mon, 19 Sep 2022 11:42:19 -0400 Subject: [PATCH 30/77] restarts have _NoFill = true we can't add fill value --- .../GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index d07c0629b..40b9b03ef 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -633,7 +633,6 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) var = Variable(type=pFIO_REAL32, dimensions='tile') call var%add_attribute('long_name', 'snow_albedo') call var%add_attribute('units', '1') - call var%add_attribute('_FillValue', MAPL_UNDEF) call this%meta%add_variable('SNOWALB', var) endif endif From 837949d6edcb42468fd6082ec5a10f7ae9eb29d3 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Mon, 19 Sep 2022 11:43:30 -0400 Subject: [PATCH 31/77] must be done some other way --- .../GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index 75d06bc1b..53f000b18 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -1381,7 +1381,6 @@ subroutine SetServices ( GC, RC ) LONG_NAME = 'snow_albedo' ,& UNITS = '1' ,& SHORT_NAME = 'SNOWALB' ,& - DEFAULT = MAPL_UNDEF ,& FRIENDLYTO = trim(COMP_NAME) ,& DIMS = MAPL_DimsTileOnly ,& VLOCATION = MAPL_VLocationNone ,& From 25534c71a4a73b5254f4b5dd2b85a5493f72c55c Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Wed, 21 Sep 2022 11:10:41 -0400 Subject: [PATCH 32/77] better choice for descriptive name --- .../GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index 53f000b18..1c421158b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -1378,7 +1378,7 @@ subroutine SetServices ( GC, RC ) if (SNOW_ALBEDO_INFO == 1) then call MAPL_AddInternalSpec(GC ,& - LONG_NAME = 'snow_albedo' ,& + LONG_NAME = 'effective_snow_albedo' ,& UNITS = '1' ,& SHORT_NAME = 'SNOWALB' ,& FRIENDLYTO = trim(COMP_NAME) ,& From 7a91c55ca9b40a0dc6259628debd5517e7350e18 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Wed, 21 Sep 2022 18:27:18 -0400 Subject: [PATCH 33/77] =?UTF-8?q?Additional=20cleanup=20and=20documentatio?= =?UTF-8?q?n:=20-=20EASE=5Fconv.F90=20=20=20-=20Added/edited=20comments=20?= =?UTF-8?q?=20=20-=20Fixed=20indentation=20=20=20-=20Cleaned=20up=20error?= =?UTF-8?q?=20messages=20=20=20-=20Replace=20=E2=80=9Cgridname=E2=80=9D=20?= =?UTF-8?q?with=20=E2=80=9CEASELabel=E2=80=9D=20-=20mkSMAPTilesPara=5Fv2.F?= =?UTF-8?q?90=20(and=20make=5Fbcs)=20=20=20-=20For=20clarity,=20replaced?= =?UTF-8?q?=20=E2=80=9Csmap=E2=80=9D=20with=20=E2=80=9Cease=E2=80=9D=20in?= =?UTF-8?q?=20variable=20names,=20print=20statements,=20comments,=20etc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Utils/Raster/EASE_conv.F90 | 180 +++++++++++------- .../Utils/Raster/make_bcs | 4 +- .../Utils/Raster/mkSMAPTilesPara_v2.F90 | 147 +++++++------- 3 files changed, 187 insertions(+), 144 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 index 8b94ca8c1..da93a3dfe 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 @@ -70,6 +70,9 @@ module EASE_conv ! ! 2022-09-13, wjiang+reichle: ! merged easeV1_conv.F90 and easeV2_conv.F90 into EASE_conv.F90 + ! - using different values for PI in easeV1 and easeV2 calcs as in old easeV[x]_conv.F90 modules; + ! in contrast, LDAS_EASE_conv.F90 in GEOSldas used only a single value for PI. + ! - bug fix in easeV2_get_params() for EASEv2/M25 (to compute s0, divide by 2.0 not by integer 2) ! ! ! ========================================================================== @@ -139,98 +142,125 @@ module EASE_conv contains ! ******************************************************************* + ! + ! GENERIC routines (public interface) + ! + ! ******************************************************************* - subroutine ease_convert (gridname, lat, lon, r, s) - character*(*), intent(in) :: gridname + subroutine ease_convert (EASELabel, lat, lon, r, s) + + character*(*), intent(in) :: EASELabel real, intent(in) :: lat, lon real, intent(out) :: r, s + character(3) :: grid - - if (index(gridname,'M36') /=0 ) then - grid='M36' - else if (index(gridname,'M25') /=0 ) then - grid='M25' - else if (index(gridname,'M09') /=0 ) then - grid='M09' - else if (index(gridname,'M03') /=0 ) then - grid='M03' - else if (index(gridname,'M01') /=0 ) then - grid='M01' + + if ( index(EASELabel,'M36') /=0 ) then + grid='M36' + else if (index(EASELabel,'M25') /=0 ) then + grid='M25' + else if (index(EASELabel,'M09') /=0 ) then + grid='M09' + else if (index(EASELabel,'M03') /=0 ) then + grid='M03' + else if (index(EASELabel,'M01') /=0 ) then + grid='M01' + else + print*,"ease_convert(): unknown grid projection and resolution: "//trim(EASELabel)//" STOPPING." + stop endif - if(index(gridname,'EASEv2') /=0) then - call easeV2_convert(grid,lat,lon,r,s) - else if(index(gridname,'EASEv1') /=0) then - call easeV1_convert(grid,lat,lon,r,s) + if( index(EASELabel,'EASEv2') /=0) then + call easeV2_convert(grid,lat,lon,r,s) + else if(index(EASELabel,'EASEv1') /=0) then + call easeV1_convert(grid,lat,lon,r,s) else - print*,"wrong gridname: "//gridname - endif - end subroutine - + print*,"ease_convert(): unknown grid version: "//trim(EASELabel)//" STOPPING." + stop + endif + + end subroutine ease_convert + ! ******************************************************************* - subroutine ease_inverse (gridname, r, s, lat, lon) - character*(*), intent(in) :: gridname + subroutine ease_inverse (EASELabel, r, s, lat, lon) + + character*(*), intent(in) :: EASELabel real, intent(in) :: r, s real, intent(out) :: lat, lon + character(3) :: grid - - if (index(gridname,'M36') /=0 ) then - grid='M36' - else if (index(gridname,'M25') /=0 ) then - grid='M25' - else if (index(gridname,'M09') /=0 ) then - grid='M09' - else if (index(gridname,'M03') /=0 ) then - grid='M03' - else if (index(gridname,'M01') /=0 ) then - grid='M01' + + if ( index(EASELabel,'M36') /=0 ) then + grid='M36' + else if (index(EASELabel,'M25') /=0 ) then + grid='M25' + else if (index(EASELabel,'M09') /=0 ) then + grid='M09' + else if (index(EASELabel,'M03') /=0 ) then + grid='M03' + else if (index(EASELabel,'M01') /=0 ) then + grid='M01' + else + print*,"ease_inverse(): unknown grid projection and resolution: "//trim(EASELabel)//" STOPPING." + stop endif - if(index(gridname,'EASEv2') /=0) then - call easeV2_inverse(grid,r,s,lat,lon) - else if(index(gridname,'EASEv1') /=0) then - call easeV1_inverse(grid,r,s,lat,lon) + if( index(EASELabel,'EASEv2') /=0) then + call easeV2_inverse(grid,r,s,lat,lon) + else if(index(EASELabel,'EASEv1') /=0) then + call easeV1_inverse(grid,r,s,lat,lon) else - print*,"wrong gridname: "//gridname - endif + print*,"ease_inverse(): unknown grid version: "//trim(EASELabel)//" STOPPING." + stop + endif + end subroutine ease_inverse + + ! ******************************************************************* + + subroutine ease_get_params (EASELabel, CELL_km, cols, rows, r0, s0, Rg ) - subroutine ease_get_params (gridname, CELL_km, cols, rows, r0, s0, Rg ) - implicit none - character*(*), intent(in) :: gridname + character*(*), intent(in) :: EASELabel real*8, intent(out) :: CELL_km integer, intent(out) :: cols, rows real*8, intent(out) :: r0, s0, Rg - + real*8 :: map_scale_m character(3) :: grid - - if (index(gridname,'M36') /=0 ) then - grid='M36' - else if (index(gridname,'M25') /=0 ) then - grid='M25' - else if (index(gridname,'M09') /=0 ) then - grid='M09' - else if (index(gridname,'M03') /=0 ) then - grid='M03' - else if (index(gridname,'M01') /=0 ) then - grid='M01' + + if ( index(EASELabel,'M36') /=0 ) then + grid='M36' + else if (index(EASELabel,'M25') /=0 ) then + grid='M25' + else if (index(EASELabel,'M09') /=0 ) then + grid='M09' + else if (index(EASELabel,'M03') /=0 ) then + grid='M03' + else if (index(EASELabel,'M01') /=0 ) then + grid='M01' + else + print*,"ease_get_params(): unknown grid projection and resolution: "//trim(EASELabel)//" STOPPING." + stop endif - if(index(gridname,'EASEv2') /=0) then - call easeV2_get_params(grid, map_scale_m, cols, rows, r0, s0) - Rg = -9999.0 - CELL_km = map_scale_m/1000.d0 - else if(index(gridname,'EASEv1') /=0) then - call easeV1_get_params(grid, CELL_km, cols, rows, r0, s0, Rg) + if( index(EASELabel,'EASEv2') /=0) then + call easeV2_get_params(grid, map_scale_m, cols, rows, r0, s0) + Rg = -9999.0 + CELL_km = map_scale_m/1000.d0 + else if(index(EASELabel,'EASEv1') /=0) then + call easeV1_get_params(grid, CELL_km, cols, rows, r0, s0, Rg) else - print*,"wrong gridname: "//gridname - endif - + print*,"ease_get_params(): unknown grid version: "//trim(EASELabel)//" STOPPING." + stop + endif + end subroutine ease_get_params - + ! ******************************************************************* + ! + ! EASEv1 routines (private) + ! ! ******************************************************************* subroutine easeV1_convert (grid, lat, lon, r, s) @@ -412,7 +442,7 @@ subroutine easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) then - print *,'Polar projections not implemented yet' + print *,'easeV1_get_params(): polar projections not implemented yet' stop else if (grid(1:1).eq.'M') then @@ -454,14 +484,14 @@ subroutine easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) else - print *,'easeV1_convert: unknown resolution: ',grid + print *,'easeV1_get_params(): unknown resolution: ',grid stop endif else - print *, 'easeV1_convert: unknown projection: ', grid + print *, 'easeV1_get_params(): unknown projection: ', grid stop endif @@ -470,6 +500,10 @@ subroutine easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) end subroutine easeV1_get_params + ! ******************************************************************* + ! + ! EASEv2 routines (private) + ! ! ******************************************************************* subroutine easeV2_convert (grid, lat, lon, col_ind, row_ind) @@ -540,7 +574,7 @@ subroutine easeV2_convert (grid, lat, lon, col_ind, row_ind) else - print *,'Polar projections not implemented yet' + print *,'EASEv2_convert(): Polar projections not implemented yet' stop endif @@ -603,7 +637,7 @@ subroutine easeV2_inverse (grid, r, s, lat, lon) else - print *,'Polar projections not implemented yet' + print *,'EASEv2_inverse(): Polar projections not implemented yet' stop endif @@ -677,19 +711,19 @@ subroutine easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) else - print *,'easeV2_convert: unknown resolution: ',grid + print *,'easeV2_get_params(): unknown resolution: ',grid stop endif else if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) then - print *,'Polar projections not implemented yet' + print *,'easeV2_get_params(): Polar projections not implemented yet' stop else - print *, 'easeV2_convert: unknown projection: ', grid + print *, 'easeV2_get_params(): unknown projection: ', grid stop endif diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index 853f08be9..c2b5244ec 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -1340,7 +1340,7 @@ if ( $EVERSION == EASEv2 ) then ## This section was used to make Irrigated Tiles ##if(${MGRID} == M09 | ${MGRID} == M36) then ## bin/mkLandRaster.x -x ${NX} -y ${NY} -v -t ${NT} - ## bin/mkSMAPTilesPara_v2.x -smap_grid ${MGRID} -pfaf_til T + ## bin/mkSMAPTilesPara_v2.x -ease_label ${MGRID} -pfaf_til T ## bin/CombineRasters.x -f 0 -t 232000000 ${THISGRID} Pfafstetter > /dev/null ## bin/CombineRasters.x -t 232000000 ${THISGRID} ${THISGRID}-Pfafstetter ## /bin/mv til/${THISGRID}_${THISGRID}-Pfafstetter.til til/${THISGRID}_${THISGRID}-Pfafstetter.ind @@ -1354,7 +1354,7 @@ endif setenv MASKFILE ${MASKFILE} setenv OMP_NUM_THREADS 1 # WY NOTE: the name mkSMAPTilesPara_v2.x will be changed to bin/bin/mkSMAPTilesPara.x -bin/mkSMAPTilesPara_v2.x -smap_grid ${BCNAME} -v $lbcsv +bin/mkSMAPTilesPara_v2.x -ease_label ${BCNAME} -v $lbcsv setenv OMP_NUM_THREADS ${NCPUS} bin/mkCatchParam.x -e EASE -g ${BCNAME} -v $lbcsv -x ${NX} -y ${NY} chmod 755 bin/create_README.csh diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index 19ccdb99f..fad515bb1 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -1,13 +1,18 @@ #include "Raster.h" PROGRAM mkSMAPTilesPara_v2 + + ! This program constructs land and lake tiles for EASE grid tile spaces such as + ! those used for the SMAP Level-4 products and other offline projects + + ! This program resulted from the merger and cleanup of mkSMAPTilesPara.F90 + ! and mkSMAPTilesPara_v2.F90 in September 2022. + ! Before the merger and cleanup, the EASE grid parameters were hard-coded here. + ! For EASEv2 M25, the outdated scale value was used here. + ! + ! - wjiang + reichle, 21 Sep 2022 + -! This program constructs land and lake tiles for the SMAP_EASEv1_Mxx -! for CLSM implementation. -! f90 -c create_smap_tiles.f90 -! f90 -c smapconv.f -! f90 -o create_smap_tiles create_smap_tiles.o smapconv.o -! use EASE_conv use rmTinyCatchParaMod use process_hres_data @@ -31,7 +36,7 @@ PROGRAM mkSMAPTilesPara_v2 INTEGER, ALLOCATABLE, DIMENSION (:) :: density, loc_int logical, dimension (:), allocatable :: unq_mask integer, pointer , dimension (:,:) :: subset - integer, pointer , dimension (:) :: subset1, subset_smap + integer, pointer , dimension (:) :: subset1 real, pointer , dimension (:) :: subset2 integer :: dx_esa, dy_esa, NBINS, NPLUS @@ -42,7 +47,7 @@ PROGRAM mkSMAPTilesPara_v2 integer,allocatable, dimension (:,:) :: catid, iaster integer,allocatable, dimension (:) :: land_id,water_id,ice_id integer,allocatable, dimension (:) :: my_land, all_id - real, allocatable, dimension (:) :: smap_grid_area,tile_area,SRTM_CatchArea + real, allocatable, dimension (:) :: ease_grid_area,tile_area,SRTM_CatchArea integer*1,allocatable, dimension (:,:) :: veg, i2aster real*4, dimension (:,:), allocatable :: q0,raster REAL, dimension (:), allocatable :: tile_ele, tile_area_land @@ -51,13 +56,13 @@ PROGRAM mkSMAPTilesPara_v2 integer l,imn,imx,jmn,jmx,mval,l_index,i_index,w_index,typ,pfaf,cindex integer :: LakeType, IceType, OceanType character(3) :: easegrid - real :: clat, clon, r_smap, s_smap, smap_convert, da + real :: clat, clon, r_ease, s_ease, da real :: fr_gcm integer :: ind_col, ind_row, status, ncid, varid, nciv,nland_cells, DOM_INDX REAL (kind=8), PARAMETER :: RADIUS=6378137.0,pi=3.14159265358979323846 character*100 :: veg_class (12) character*100 :: gfile,gtopo30 - integer :: nc_smap,nr_smap, N_args, command_argument_count + integer :: nc_ease,nr_ease, N_args, command_argument_count real*8 :: CELL_km REAL :: dx,dy,d2r,lats,mnx,mxx,mny,mxy,sum1,sum2,jgv, VDUM,pix_area character(40) :: arg, EASElabel_ @@ -70,13 +75,18 @@ PROGRAM mkSMAPTilesPara_v2 character(len=6) :: EASE_Version real*8 :: r0, s0, Rg character(len=10) :: nc_string, nr_string + character(128) :: usage1, usage2 + + ! -------------------------------------------------------------------------------------- + + usage1 = 'USAGE : bin/mkEASETiles -ease_label EASELabel -v LBCSV ' + usage2 = ' where EASELabel = *EASEv[x]_M[yy]*, x={1,2}, yy={01,03,09,25,36}' N_args = command_argument_count() if(N_args < 1) then - print *,'USAGE : bin/mkSMAPTiles -smap_grid EASELabel -v LBCSV' - print *,'Allowed SMAP grids are: SMAP_EASEv1_M01 M03 M09 M25 M36' - print *,'Allowed SMAP grids are: SMAP_EASEv2_M01 M03 M09 M25 M36' + print *,trim(usage1) + print *,trim(usage2) stop end if @@ -87,7 +97,7 @@ PROGRAM mkSMAPTilesPara_v2 call get_command_argument(i,arg) - if ( trim(arg) == '-smap_grid' ) then + if ( trim(arg) == '-ease_label' ) then i = i+1 call get_command_argument(i,EASELabel_) @@ -102,9 +112,8 @@ PROGRAM mkSMAPTilesPara_v2 call get_command_argument(i,LBCSV) else ! stop for any other arguments - print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX -v LBCSV -ease_version xx' - print *,'Allowed SMAP grids are: M01, M03, M09, M25, M36 ' - print *,'Allowed ease_version are: EASEv1 EASEv2' + print *,trim(usage1) + print *,trim(usage2) stop endif @@ -119,23 +128,23 @@ PROGRAM mkSMAPTilesPara_v2 !call execute_command_line('cd data/ ; ln -s /discover/nobackup/projects/gmao/ssd/land/l_data/LandBCs_files_for_mkCatchParam/V001/ CATCH') !call execute_command_line('cd ..') - ! Setting SMAP Grid specifications + ! Setting EASE Grid specifications ! -------------------------------- EASElabel = trim(EASELabel_) - call ease_get_params(EASELabel, CELL_km, nc_smap, nr_smap, r0,s0, Rg) - write(nc_string, '(i0)') nc_smap - write(nr_string, '(i0)') nr_smap + call ease_get_params(EASELabel, CELL_km, nc_ease, nr_ease, r0,s0, Rg) + write(nc_string, '(i0)') nc_ease + write(nr_string, '(i0)') nr_ease gfile = trim(EASElabel)//'_'//trim(nc_string)//'x'//trim(nc_string) - if (index(EASELabel,'M03') /=0) then ! SMAP 3 km grid + if (index(EASELabel,'M03') /=0) then ! EASE 3 km grid regrid = .true. NC = 21600 NR = 10800 NT = 500000000 endif - if (index(EASELabel,'M03') /=0) then ! SMAP 1 km grid + if (index(EASELabel,'M03') /=0) then ! EASE 1 km grid regrid = .true. NC = 43200 NR = 21600 @@ -145,7 +154,7 @@ PROGRAM mkSMAPTilesPara_v2 if ( .not. (index(EASELabel,'M01') /=0 .or. index(EASELabel,'M03') /=0 .or. & index(EASELabel,'M09') /=0 .or. index(EASELabel,'M25') /=0 .or. & index(EASELabel,'M36') /=0)) then - print*,'Unknown SMAP Grid stopping..' + print*,'Unknown EASE grid projection and resolution: '//trim(EASELabel)//' STOPPING.' stop endif @@ -159,7 +168,7 @@ PROGRAM mkSMAPTilesPara_v2 IceType =11 LakeType =10 - ND = 10*10**(nint(log10(1.*nr_smap))) + ND = 10*10**(nint(log10(1.*nr_ease))) ! Check for the 10 arc-sec MaskFile ! ----------------------------------- @@ -181,7 +190,7 @@ PROGRAM mkSMAPTilesPara_v2 if (index(MaskFile,'GEOS5_10arcsec_mask') /= 0) then ! New ESA (Veg) + SRTM (catchments) based mask file - ! is overlaid on SMAP + ! is overlaid on the EASE grid ! ------------------------------------------------- nc = 43200 ! Number of rows in raster file @@ -286,14 +295,14 @@ PROGRAM mkSMAPTilesPara_v2 if(catid_index (i,j) == SRTM_maxcat + 2) veg (i,j) = IceType if((catid_index(i,j) >= 1).and.(catid_index (i,j) <= SRTM_maxcat)) i1 = i1 + 1 - ! count in if this is i,j pixel is a land, lake or ice within ind_col,ind_row SMAP grid cell + ! count in if this is i,j pixel is a land, lake or ice within ind_col,ind_row EASE grid cell - call EASE_convert(EASELabel, clat, clon, r_smap, s_smap) + call EASE_convert(EASELabel, clat, clon, r_ease, s_ease) - ind_col = nint(r_smap) + 1 - ind_row = nint(s_smap) + 1 + ind_col = nint(r_ease) + 1 + ind_row = nint(s_ease) + 1 - if((ind_row.ge.1).and.(veg(i,j).ne.OceanType).and.(ind_row.le.nr_smap)) then + if((ind_row.ge.1).and.(veg(i,j).ne.OceanType).and.(ind_row.le.nr_ease)) then l= ind_row*ND + ind_col if(veg(i,j)==LakeType) then @@ -317,7 +326,7 @@ PROGRAM mkSMAPTilesPara_v2 else ! Old IGBP (Veg) + HYDRO1k (catchments) based mask will - ! Overlaid on SMAP mask + ! Overlaid on EASE mask ! ----------------------------------------------------- allocate(iaster (i_raster,j_raster)) @@ -428,11 +437,11 @@ PROGRAM mkSMAPTilesPara_v2 print *,'Min and Max of tile indices:',minval(catid_index),maxval(catid_index) ! While looping through the nc x nr grid (tile raster), this section counts # of - ! SMAP grid cells that contain land, ice or water, seperately. - ! Each SMAP grid cell is assigned with an ID = ind_row*ND + ind_col. + ! EASE grid cells that contain land, ice or water, seperately. + ! Each EASE grid cell is assigned with an ID = ind_row*ND + ind_col. ! This is just the prelimiminery assessment in the process of assigning separate - ! tiles for land, water and ice fractions within the SMAP Grid cell - ! The program checks each nc x nr pixels whether there is a SMAP grid cell underneath, and counts + ! tiles for land, water and ice fractions within the EASE Grid cell + ! The program checks each nc x nr pixels whether there is a EASE grid cell underneath, and counts ! number of water, land and ice pixels as seen on veg raster. ! ----------------------------------------------------------------------------------------------- @@ -444,12 +453,12 @@ PROGRAM mkSMAPTilesPara_v2 do j =nr ,1 ,-1 clat = -90. + float(j-1)*dy + dy/2. - call EASE_convert(EASELabel, clat, clon, r_smap, s_smap) + call EASE_convert(EASELabel, clat, clon, r_ease, s_ease) - ind_col = nint(r_smap) + 1 - ind_row = nint(s_smap) + 1 + ind_col = nint(r_ease) + 1 + ind_row = nint(s_ease) + 1 - if((ind_row.ge.1).and.(veg(i,j).ne.OceanType).and.(ind_row.le.nr_smap)) then + if((ind_row.ge.1).and.(veg(i,j).ne.OceanType).and.(ind_row.le.nr_ease)) then l= ind_row*ND + ind_col if(veg(i,j)==LakeType) then @@ -485,9 +494,9 @@ PROGRAM mkSMAPTilesPara_v2 deallocate (raster) - print *,'# of Land pixels in SMAP: ',sum (land_id) - print *,'# of water pixels in SMAP: ',sum (water_id) - print *,'# of ice pixels in SMAP: ',sum (ice_id) + print *,'# of Land pixels in EASE: ',sum (land_id) + print *,'# of water pixels in EASE: ',sum (water_id) + print *,'# of ice pixels in EASE: ',sum (ice_id) l_index=0 w_index=sum (land_id) @@ -496,7 +505,7 @@ PROGRAM mkSMAPTilesPara_v2 allocate(tile_area (1:i_index + sum (ice_id))) - allocate(smap_grid_area (1:NT)) + allocate(ease_grid_area (1:NT)) allocate(tile_ele (1:w_index)) allocate(tile_area_land(1:w_index)) allocate(my_land (1:i_index + sum (ice_id))) @@ -508,18 +517,18 @@ PROGRAM mkSMAPTilesPara_v2 my_land = 0 all_id = 0 - smap_grid_area = 0. + ease_grid_area = 0. tile_area_land = 0. tile_ele = 0. tile_area = 0. ! While looping through the nc x nr grid, this section derives land, ice and water tiles. - ! Each SMAP grid cell is assigned with an ID = ind_row*ND + ind_col - ! ind_col, ind_row are overlying SMAP grid cell indices + ! Each EASE grid cell is assigned with an ID = ind_row*ND + ind_col + ! ind_col, ind_row are overlying EASE grid cell indices ! Based on the above sums: ! l_index Grid cells have land fractions (sum(land_id)) - ! w_index SMAP Grid cells have inland water fractions (sum(water_id)) - ! i_index SMAP Grid cells have ice fractions (sum(ice_id)) + ! w_index EASE Grid cells have inland water fractions (sum(water_id)) + ! i_index EASE Grid cells have ice fractions (sum(ice_id)) ! hence, tile_index 1 to l_index represent land tiles ! tile_index l_index +1 to l_index + w_index represent water (lakes) tiles ! tile_index l_index + w_index +1 to l_index + w_index + i_index represent ice tiles @@ -536,15 +545,15 @@ PROGRAM mkSMAPTilesPara_v2 do j =nr ,1 ,-1 lats = -90._8 + (j - 0.5_8)*dy clat = -90. + float(j-1)*dy + dy/2. - call EASE_convert(EASELabel, clat, clon, r_smap, s_smap) + call EASE_convert(EASELabel, clat, clon, r_ease, s_ease) - ind_col = nint(r_smap) + 1 - ind_row = nint(s_smap) + 1 + ind_col = nint(r_ease) + 1 + ind_row = nint(s_ease) + 1 l= ind_row*ND + ind_col pix_area =(sin(d2r*(lats+0.5*dy)) -sin(d2r*(lats-0.5*dy)))*(dx*d2r) - if((ind_row.ge.1).and.(veg(i,j).ge.1).and.(ind_row.le.nr_smap)) then + if((ind_row.ge.1).and.(veg(i,j).ge.1).and.(ind_row.le.nr_ease)) then if(veg(i,j)==LakeType) then if(water_id(l)==0) then @@ -582,8 +591,8 @@ PROGRAM mkSMAPTilesPara_v2 all_id (tileid_index(i,j)) = j*ND_raster + i endif - if((ind_row.ge.1).and.(ind_row.le.nr_smap)) then - smap_grid_area(l) = smap_grid_area(l) + & + if((ind_row.ge.1).and.(ind_row.le.nr_ease)) then + ease_grid_area(l) = ease_grid_area(l) + & pix_area endif @@ -652,8 +661,8 @@ PROGRAM mkSMAPTilesPara_v2 write (10,*)i_index,SRTM_maxcat, nc, nr write (10,*)1 write (10,*)EASELabel - write (10,*)nc_smap - write (10,*)nr_smap + write (10,*)nc_ease + write (10,*)nr_ease ! write (10,*)'NO-OCEAN' ! write (10,*) -9999 ! write (10,*) -9999 @@ -678,8 +687,8 @@ PROGRAM mkSMAPTilesPara_v2 typ = 100 call EASE_inverse (EASELabel, real(ig-1),real(jg-1), clat, clon) - mnx = clon - 180./real(nc_smap) - mxx = clon + 180./real(nc_smap) + mnx = clon - 180./real(nc_ease) + mxx = clon + 180./real(nc_ease) jgv = real(jg-1) + 0.5 @@ -699,7 +708,7 @@ PROGRAM mkSMAPTilesPara_v2 call EASE_inverse (EASELabel, real(ig-1), real(jg-1), clat, clon) - fr_gcm= tile_area(l)/smap_grid_area(jg*ND + ig) + fr_gcm= tile_area(l)/ease_grid_area(jg*ND + ig) if (index(MaskFile,'GEOS5_10arcsec_mask') /= 0) then write(10,'(i10,i9,2f10.4,2i6,f19.12,i10,i15,e13.4)') & @@ -715,7 +724,7 @@ PROGRAM mkSMAPTilesPara_v2 close (11,status='keep') deallocate (tileid_index,catid_index,veg) - deallocate (tile_area, smap_grid_area, tile_ele, tile_area_land, my_land, all_id) + deallocate (tile_area, ease_grid_area, tile_ele, tile_area_land, my_land, all_id) if (index(MaskFile,'GEOS5_10arcsec_mask') /= 0) then @@ -759,21 +768,21 @@ PROGRAM mkSMAPTilesPara_v2 !!! real*8, allocatable :: xs(:,:), ys(:,:) !!! real :: x,y, xout, yout !!! -!!! allocate (xs ( nc_smap+1, nr_smap+1)) -!!! allocate (ys ( nc_smap+1, nr_smap+1)) +!!! allocate (xs ( nc_ease+1, nr_ease+1)) +!!! allocate (ys ( nc_ease+1, nr_ease+1)) !!! -!!! do j = 1, nr_smap+1 -!!! do i = 1, nc_smap+1 +!!! do j = 1, nr_ease+1 +!!! do i = 1, nc_ease+1 !!! x = real(i-1) -0.5 -!!! y = real(nr_smap - j)+0.5 +!!! y = real(nr_ease - j)+0.5 !!! call EASE_inverse(MGRID, x, y, yout, xout) !!! ys (i,j) = dble(yout) !!! xs (i,j) = dble(xout) !!! end do !!! end do !!! -!!! call LRRasterize(EASElabel,xs,ys,nc=nc,nr=nr,xmn = xs(1,1), xmx= xs(nc_smap+1, nr_smap+1), & -!!! ymn=ys(1,1), ymx = ys(nc_smap+1, nr_smap+1), Here=.false., Verb=.false.) +!!! call LRRasterize(EASElabel,xs,ys,nc=nc,nr=nr,xmn = xs(1,1), xmx= xs(nc_ease+1, nr_ease+1), & +!!! ymn=ys(1,1), ymx = ys(nc_ease+1, nr_ease+1), Here=.false., Verb=.false.) !!! !!! stop !!! end SUBROUTINE mkEASEv2Raster @@ -819,7 +828,7 @@ PROGRAM mkSMAPTilesPara_v2 !!! rRtable(1,2),rRtable(1,3),iRtable (1,2),iRtable (1,3),rRtable(1,4),iRtable (1,4),& !!! iRtable (1,5),iRtable (1,6),rRtable(1,5),iRtable (1,7) !!! write(11,'(I10,3E20.12,9(2I10,E20.12,I10))') iRtable (1,1),rRtable(1,1), & -!!! rRtable(1,2),rRtable(1,3),iRtable (1,2)-1,nr_smap - iRtable (1,3),rRtable(1,4),iRtable (1,4),& +!!! rRtable(1,2),rRtable(1,3),iRtable (1,2)-1,nr_ease - iRtable (1,3),rRtable(1,4),iRtable (1,4),& !!! iRtable (1,5),iRtable (1,6),rRtable(1,5),iRtable (1,7) !!! end do !!! From d692b0cb0c928fd0f9e166ad0fced687b8754809 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang <52509753+weiyuan-jiang@users.noreply.github.com> Date: Thu, 22 Sep 2022 09:14:31 -0400 Subject: [PATCH 34/77] fix typo --- .../GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index fad515bb1..09fdd23ef 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -136,7 +136,7 @@ PROGRAM mkSMAPTilesPara_v2 call ease_get_params(EASELabel, CELL_km, nc_ease, nr_ease, r0,s0, Rg) write(nc_string, '(i0)') nc_ease write(nr_string, '(i0)') nr_ease - gfile = trim(EASElabel)//'_'//trim(nc_string)//'x'//trim(nc_string) + gfile = trim(EASElabel)//'_'//trim(nc_string)//'x'//trim(nr_string) if (index(EASELabel,'M03') /=0) then ! EASE 3 km grid regrid = .true. From 614a304aa875e4b9ae19ada17d8fd4d5b71836a9 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Thu, 22 Sep 2022 09:55:00 -0400 Subject: [PATCH 35/77] Additional cleanup: - replaced ease_get_params() with simpler ease_extent() (EASE_conv.F90, mkSMAPTilesPara_v2.F90) - renamed EVERSION to EASEVERSION for clarity (make_bcs) --- .../Utils/Raster/EASE_conv.F90 | 49 ++++++------------- .../Utils/Raster/make_bcs | 30 ++++++------ .../Utils/Raster/mkSMAPTilesPara_v2.F90 | 24 +++------ 3 files changed, 39 insertions(+), 64 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 index da93a3dfe..df9c26ea1 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 @@ -83,7 +83,7 @@ module EASE_conv public :: ease_convert public :: ease_inverse - public :: ease_get_params + public :: ease_extent ! ======================================================================= ! @@ -146,6 +146,12 @@ module EASE_conv ! GENERIC routines (public interface) ! ! ******************************************************************* + ! + ! EASELabel = *EASEv[x]_[p][yy]* (e.g., EASEv2_M09) + ! + ! version: x = { 1, 2 } + ! projection: p = { M } ! only cylindrical ("M") implemented + ! resolution: yy = { 01, 03, 09, 25, 36 } ! 12.5 km not yet implemented subroutine ease_convert (EASELabel, lat, lon, r, s) @@ -219,15 +225,13 @@ end subroutine ease_inverse ! ******************************************************************* - subroutine ease_get_params (EASELabel, CELL_km, cols, rows, r0, s0, Rg ) + subroutine ease_extent (EASELabel, cols, rows ) character*(*), intent(in) :: EASELabel - real*8, intent(out) :: CELL_km integer, intent(out) :: cols, rows - real*8, intent(out) :: r0, s0, Rg - - real*8 :: map_scale_m - character(3) :: grid + + real*8 :: map_scale_m, CELL_km, r0, s0, Rg + character(3) :: grid if ( index(EASELabel,'M36') /=0 ) then grid='M36' @@ -240,23 +244,22 @@ subroutine ease_get_params (EASELabel, CELL_km, cols, rows, r0, s0, Rg ) else if (index(EASELabel,'M01') /=0 ) then grid='M01' else - print*,"ease_get_params(): unknown grid projection and resolution: "//trim(EASELabel)//" STOPPING." + print*,"ease_extent(): unknown grid projection and resolution: "//trim(EASELabel)//" STOPPING." stop endif if( index(EASELabel,'EASEv2') /=0) then call easeV2_get_params(grid, map_scale_m, cols, rows, r0, s0) - Rg = -9999.0 - CELL_km = map_scale_m/1000.d0 else if(index(EASELabel,'EASEv1') /=0) then call easeV1_get_params(grid, CELL_km, cols, rows, r0, s0, Rg) else - print*,"ease_get_params(): unknown grid version: "//trim(EASELabel)//" STOPPING." + print*,"ease_extent(): unknown grid version: "//trim(EASELabel)//" STOPPING." stop endif - end subroutine ease_get_params + end subroutine ease_extent + ! ******************************************************************* ! ! EASEv1 routines (private) @@ -500,6 +503,7 @@ subroutine easeV1_get_params( grid, CELL_km, cols, rows, r0, s0, Rg ) end subroutine easeV1_get_params + ! ******************************************************************* ! ! EASEv2 routines (private) @@ -731,27 +735,6 @@ subroutine easeV2_get_params( grid, map_scale_m, cols, rows, r0, s0 ) end subroutine easeV2_get_params ! ******************************************************************* - - subroutine easeV2_extent( grid, N_cols, N_rows ) - - ! simple wrapper to get N_cols (N_lon) and N_rows (N_lat) - - implicit none - - character*(*), intent(in) :: grid - integer, intent(out) :: N_cols, N_rows - - ! local variables - - real*8 :: map_scale_m, r0, s0 - - ! ------------------------------------------------ - - call easeV2_get_params( grid, map_scale_m, N_cols, N_rows, r0, s0 ) - - end subroutine easeV2_extent - - ! ******************************************************************* end module EASE_conv diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index c2b5244ec..b2a035bb5 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -254,8 +254,8 @@ if ( $HELPMODE != YES ) then if( $dummy == 'EASEv1' | \ $dummy == 'EASEv2') then - set EVERSION = $dummy - echo "EASE grid Version is ${EVERSION} " + set EASEVERSION = $dummy + echo "EASE grid Version is ${EASEVERSION} " else echo " " echo " Invalid input, please use EASEv1 or EASEv2 " @@ -1282,19 +1282,19 @@ if( $grid == ease ) then #WY noted: ease version becomes input #if( $HRCODE == m25 ) then - # set EVERSION = EASEv1 + # set EASEVERSION = EASEv1 #else - # set EVERSION = EASEv2 + # set EASEVERSION = EASEv2 #endif set RS = ${im}x${jm} set IM = `echo ${im} | awk '{printf "%4.4i", $1}'` set JM = `echo ${jm} | awk '{printf "%4.4i", $1}'` - set BCNAME = SMAP_${EVERSION}_${MGRID} + set BCNAME = SMAP_${EASEVERSION}_${MGRID} set BCDIR = $EXPDIR/$OUTDIR/$BCNAME.scratch set BCJOB = $BCDIR/$BCNAME.j - set THISGRID = SMAP-${EVERSION}-${MGRID} + set THISGRID = SMAP-${EASEVERSION}-${MGRID} set nfiles = `find $EXPDIR -maxdepth 5 -name ${BCNAME}".j" | wc -l` if( $nfiles >= 1 ) then @@ -1336,7 +1336,7 @@ ln -s $input_dir CATCH cd ../ limit stacksize unlimited -if ( $EVERSION == EASEv2 ) then +if ( $EASEVERSION == EASEv2 ) then ## This section was used to make Irrigated Tiles ##if(${MGRID} == M09 | ${MGRID} == M36) then ## bin/mkLandRaster.x -x ${NX} -y ${NY} -v -t ${NT} @@ -1346,7 +1346,7 @@ if ( $EVERSION == EASEv2 ) then ## /bin/mv til/${THISGRID}_${THISGRID}-Pfafstetter.til til/${THISGRID}_${THISGRID}-Pfafstetter.ind ##endif endif -if ( $EVERSION == EASEv1 ) then +if ( $EASEVERSION == EASEv1 ) then ## for easev1, default values set lbcsv = UNDEF endif @@ -1361,7 +1361,7 @@ chmod 755 bin/create_README.csh bin/create_README.csh /bin/mv clsm clsm.${IM}x${JM} -/bin/cp til/SMAP_${EVERSION}_${MGRID}_${RS}.til clsm.${IM}x${JM} +/bin/cp til/SMAP_${EASEVERSION}_${MGRID}_${RS}.til clsm.${IM}x${JM} ##/bin/cp til//${THISGRID}_${THISGRID}-Pfafstetter.TIL clsm.${IM}x${JM} cd clsm.${IM}x${JM} @@ -1377,9 +1377,9 @@ cd clsm.${IM}x${JM} cd ../ -/bin/rm -rf SMAP_${EVERSION}_${MGRID} -/bin/mv clsm.${IM}x${JM} SMAP_${EVERSION}_${MGRID} - cd SMAP_${EVERSION}_${MGRID} +/bin/rm -rf SMAP_${EASEVERSION}_${MGRID} +/bin/mv clsm.${IM}x${JM} SMAP_${EASEVERSION}_${MGRID} + cd SMAP_${EASEVERSION}_${MGRID} mkdir clsm /bin/mv ar.new \ bf.dat \ @@ -1409,8 +1409,8 @@ cd ../ clsm cd ../ -/bin/mv rst SMAP_${EVERSION}_${MGRID} -/bin/mv til SMAP_${EVERSION}_${MGRID} +/bin/mv rst SMAP_${EASEVERSION}_${MGRID} +/bin/mv til SMAP_${EASEVERSION}_${MGRID} cd ../../ /bin/mv $BCDIR/$BCNAME . @@ -1420,7 +1420,7 @@ cd ../../ /bin/rm -r $OUTDIR #mkdir -p IRRIG/$BCNAME/clsm IRRIG/$BCNAME/rst -#bin/mkIrrigTiles.x -x 43200 -y 21600 -b $BCNAME -t SMAP_${EVERSION}_${MGRID}_${RS}.til -r _${RS}_DE -p $IRRIGTHRES +#bin/mkIrrigTiles.x -x 43200 -y 21600 -b $BCNAME -t SMAP_${EASEVERSION}_${MGRID}_${RS}.til -r _${RS}_DE -p $IRRIGTHRES #/bin/cp $BCNAME/${THISGRID}_${THISGRID}-Pfafstetter.TIL IRRIG/$BCNAME/. _EOF_ diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index 09fdd23ef..68948d0c2 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -63,7 +63,6 @@ PROGRAM mkSMAPTilesPara_v2 character*100 :: veg_class (12) character*100 :: gfile,gtopo30 integer :: nc_ease,nr_ease, N_args, command_argument_count - real*8 :: CELL_km REAL :: dx,dy,d2r,lats,mnx,mxx,mny,mxy,sum1,sum2,jgv, VDUM,pix_area character(40) :: arg, EASElabel_ character(len=:), allocatable :: EASElabel @@ -73,7 +72,6 @@ PROGRAM mkSMAPTilesPara_v2 logical :: pfaf_til = .false. character*1 :: PF character(len=6) :: EASE_Version - real*8 :: r0, s0, Rg character(len=10) :: nc_string, nr_string character(128) :: usage1, usage2 @@ -133,7 +131,7 @@ PROGRAM mkSMAPTilesPara_v2 EASElabel = trim(EASELabel_) - call ease_get_params(EASELabel, CELL_km, nc_ease, nr_ease, r0,s0, Rg) + call ease_extent(EASELabel, nc_ease, nr_ease ) write(nc_string, '(i0)') nc_ease write(nr_string, '(i0)') nr_ease gfile = trim(EASElabel)//'_'//trim(nc_string)//'x'//trim(nr_string) @@ -150,23 +148,17 @@ PROGRAM mkSMAPTilesPara_v2 NR = 21600 NT = 1500000000 endif - ! - if ( .not. (index(EASELabel,'M01') /=0 .or. index(EASELabel,'M03') /=0 .or. & - index(EASELabel,'M09') /=0 .or. index(EASELabel,'M25') /=0 .or. & - index(EASELabel,'M36') /=0)) then - print*,'Unknown EASE grid projection and resolution: '//trim(EASELabel)//' STOPPING.' - stop - endif allocate(land_id (1:NT)) allocate(water_id (1:NT)) allocate(ice_id (1:NT)) - land_id = 0 - water_id = 0 - ice_id = 0 - OceanType = 0 - IceType =11 - LakeType =10 + + land_id = 0 + water_id = 0 + ice_id = 0 + OceanType = 0 + IceType = 11 + LakeType = 10 ND = 10*10**(nint(log10(1.*nr_ease))) From 3d668db82394f7d0f270b536ac76ce85a3b29318 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Mon, 26 Sep 2022 09:33:14 -0400 Subject: [PATCH 36/77] 1)correct 'gfile' for EASE in mkCatchParam 2)set the number of threads for mkCatchParam.( need to clean up in the future) --- .../Utils/Raster/make_bcs | 16 +++++----- .../Utils/Raster/mkCatchParam.F90 | 31 ++++++++++--------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index b2a035bb5..4df88f0c6 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -1286,6 +1286,10 @@ if( $grid == ease ) then #else # set EASEVERSION = EASEv2 #endif + if ( $EASEVERSION == EASEv1 ) then + ## for easev1, default values + set lbcsv = UNDEF + endif set RS = ${im}x${jm} set IM = `echo ${im} | awk '{printf "%4.4i", $1}'` @@ -1336,7 +1340,7 @@ ln -s $input_dir CATCH cd ../ limit stacksize unlimited -if ( $EASEVERSION == EASEv2 ) then +#if ( $EASEVERSION == EASEv2 ) then ## This section was used to make Irrigated Tiles ##if(${MGRID} == M09 | ${MGRID} == M36) then ## bin/mkLandRaster.x -x ${NX} -y ${NY} -v -t ${NT} @@ -1345,18 +1349,16 @@ if ( $EASEVERSION == EASEv2 ) then ## bin/CombineRasters.x -t 232000000 ${THISGRID} ${THISGRID}-Pfafstetter ## /bin/mv til/${THISGRID}_${THISGRID}-Pfafstetter.til til/${THISGRID}_${THISGRID}-Pfafstetter.ind ##endif -endif -if ( $EASEVERSION == EASEv1 ) then - ## for easev1, default values - set lbcsv = UNDEF -endif +#endif setenv MASKFILE ${MASKFILE} setenv OMP_NUM_THREADS 1 # WY NOTE: the name mkSMAPTilesPara_v2.x will be changed to bin/bin/mkSMAPTilesPara.x bin/mkSMAPTilesPara_v2.x -ease_label ${BCNAME} -v $lbcsv +setenv OMP_NUM_THREADS 1 +bin/mkCatchParam.x -g ${BCNAME} -v $lbcsv -x ${NX} -y ${NY} setenv OMP_NUM_THREADS ${NCPUS} -bin/mkCatchParam.x -e EASE -g ${BCNAME} -v $lbcsv -x ${NX} -y ${NY} +bin/mkCatchParam.x -g ${BCNAME} -v $lbcsv -x ${NX} -y ${NY} chmod 755 bin/create_README.csh bin/create_README.csh diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index b07b9ba3b..fb16fbaab 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -4,14 +4,12 @@ PROGRAM mkCatchParam ! ! !ARGUMENTS: ! -! Usage = "mkCatchParam -x nx -y ny -g Gridname -b DL -v LBCSV -e EASE" +! Usage = "mkCatchParam -x nx -y ny -g Gridname -b DL -v LBCSV " ! -x: Size of longitude dimension of input raster. DEFAULT: 8640 ! -y: Size of latitude dimension of input raster. DEFAULT: 4320 ! -b: position of the dateline in the first box. DEFAULT: DC ! -g: Gridname (name of the .til or .rst file without file extension) ! -v: LBCSV : Land bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) -! -e: EASE : This is optional if catchment.def file is available already or -! the til file format is pre-Fortuna-2. ! ! ! This program is good to generate @@ -20,7 +18,7 @@ PROGRAM mkCatchParam ! ! Sarith Mahanama - March 23, 2012 ! Email: sarith.p.mahanama@nasa.gov - + use EASE_conv use rmTinyCatchParaMod use process_hres_data ! use module_irrig_params, ONLY : create_irrig_params @@ -40,7 +38,6 @@ PROGRAM mkCatchParam character*1 :: opt character*7 :: PEATSOURCE = 'GDLHWSD' character*3 :: VEGZSOURCE = 'D&S' - character*4 :: EASE =' ' character*2 :: DL ='DC' integer :: II, JJ, Type integer :: I, J, command_argument_count, nxt @@ -61,6 +58,8 @@ PROGRAM mkCatchParam character*200 :: fname_tmp, fname_tmp2, fname_tmp3, fname_tmp4 integer :: N_tile logical :: process_snow_albedo = .false. + character(len=10) :: nc_string, nr_string + integer :: nc_ease, nr_ease ! --------- VARIABLES FOR *OPENMP* PARALLEL ENVIRONMENT ------------ ! @@ -103,14 +102,12 @@ PROGRAM mkCatchParam ! call execute_command_line('cd data/ ; ln -s /discover/nobackup/projects/gmao/ssd/land/l_data/LandBCs_files_for_mkCatchParam/V001/ CATCH') ! call execute_command_line('cd ..') - USAGE(1) ="Usage: mkCatchParam -x nx -y ny -g Gridname -b DL -v LBCSV -e EASE " + USAGE(1) ="Usage: mkCatchParam -x nx -y ny -g Gridname -b DL -v LBCSV " USAGE(2) =" -x: Size of longitude dimension of input raster. DEFAULT: 8640 " USAGE(3) =" -y: Size of latitude dimension of input raster. DEFAULT: 4320 " USAGE(4) =" -g: Gridname (name of the .til or .rst file without file extension) " USAGE(5) =" -b: Position of the dateline in the first grid box (DC or DE). DEFAULT: DC " - USAGE(6) =" -e: EASE : This is optional if catchment.def file is available already or " - USAGE(7) =" the til file format is pre-Fortuna-2. " - USAGE(8) =" -v LBCSV : Land bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) " + USAGE(6) =" -v LBCSV : Land bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) " ! Process Arguments !------------------ @@ -159,9 +156,6 @@ PROGRAM mkCatchParam call init_bcs_config (trim(LBCSV)) ! get bcs details from version string case ('b') DL = trim(arg) - case ('e') - EASE = trim(arg) - if(EASE=='EASE') ease_grid=.true. case default do j = 1,size(usage) print "(sp,a100)", Usage(j) @@ -174,17 +168,26 @@ PROGRAM mkCatchParam call get_environment_variable ("MASKFILE" ,MaskFile ) - if(trim(Gridname) == '') then + if(trim(Gridname) == '') then write (log_file,'(a)')'Unable to create parameters without til/rst files.... !' stop endif regrid = nc/=i_raster .or. nr/=j_raster + + if (index(Gridname,'EASEv') /=0) then + ! here gridname has alias EASELabel + call ease_extent(Gridname, nc_ease, nr_ease ) + write(nc_string, '(i0)') nc_ease + write(nr_string, '(i0)') nr_ease + gridname = trim(Gridname)//'_'//trim(nc_string)//'x'//trim(nr_string) + ease_grid = .true. + endif if(index(Gridname,'Pfaf.notiny')/=0) then GridnameR='clsm/'//trim(Gridname) GridnameT='clsm/'//trim(Gridname) - else + else GridnameR='rst/'//trim(Gridname) GridnameT='til/'//trim(Gridname) endif From a24fecdc24fe4ec68b0718f1d29b88cbac335498 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Mon, 26 Sep 2022 09:40:34 -0400 Subject: [PATCH 37/77] correct printing suffix .rst --- .../GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 index 68948d0c2..9f90710c9 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 @@ -628,7 +628,7 @@ PROGRAM mkSMAPTilesPara_v2 print *,'Total Land Area :', sum(tile_area(1:l_index))* MAPL_RADIUS * MAPL_RADIUS/1000./1000., & sum(tile_area_land(1:l_index))* MAPL_RADIUS * MAPL_RADIUS/1000./1000. - print *,'Creating ... ', trim(gfile)//'rst' + print *,'Creating ... ', trim(gfile)//'.rst' !------------------------------------------- @@ -641,7 +641,7 @@ PROGRAM mkSMAPTilesPara_v2 close (10,status='keep') - print *,'Creating ... ', trim(gfile)//'til ,catchment.def' + print *,'Creating ... ', trim(gfile)//'.til ,catchment.def' !----------------------------------------------------------- From 6b0d42772761a241560d59165960d572d76b25f3 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Mon, 26 Sep 2022 09:58:40 -0400 Subject: [PATCH 38/77] reduce usage dimension --- .../GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index fb16fbaab..84a2ca9ca 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -43,7 +43,7 @@ PROGRAM mkCatchParam integer :: I, J, command_argument_count, nxt real*8 :: dx, dy, lon0 logical :: regrid - character(len=400), dimension (8) :: Usage + character(len=400), dimension (6) :: Usage character*128 :: Grid2 character*2 :: poles character*128 :: GridNameR = '' From c545dee48abcfd3df44db7fe6646116593dbd508 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Tue, 27 Sep 2022 08:13:12 -0400 Subject: [PATCH 39/77] rename mkSMAPTiles... to mkEASETiles... --- .../Utils/Raster/CMakeLists.txt | 3 +- .../Utils/Raster/make_bcs | 6 +- ...PTilesPara_v2.F90 => mkEASETilesParam.F90} | 5 +- .../Utils/Raster/mkSMAPTilesPara.F90 | 696 ------------------ 4 files changed, 7 insertions(+), 703 deletions(-) rename GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/{mkSMAPTilesPara_v2.F90 => mkEASETilesParam.F90} (99%) delete mode 100644 GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara.F90 diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt index be0b731ce..4005c9fcf 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt @@ -44,7 +44,6 @@ ecbuild_add_executable (TARGET mkMITAquaRaster.x SOURCES mkMITAquaRaster.F90 LIB ecbuild_add_executable (TARGET mkMOMAquaRaster.x SOURCES mkMOMAquaRaster.F90 LIBS MAPL ${this}) ecbuild_add_executable (TARGET FillMomGrid.x SOURCES FillMomGrid.F90 LIBS MAPL ${this}) ecbuild_add_executable (TARGET mk_runofftbl.x SOURCES mk_runofftbl.F90 LIBS MAPL ${this}) -#ecbuild_add_executable (TARGET mkSMAPTilesPara.x SOURCES mkSMAPTilesPara.F90 LIBS MAPL ${this}) -ecbuild_add_executable (TARGET mkSMAPTilesPara_v2.x SOURCES mkSMAPTilesPara_v2.F90 LIBS MAPL ${this}) +ecbuild_add_executable (TARGET mkEASETilesParam.x SOURCES mkEASETilesParam.F90 LIBS MAPL ${this}) install(PROGRAMS make_bcs clsm_plots.pro plot_curves.pro create_README.csh plot_curves.csh DESTINATION bin) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index 4df88f0c6..5b9a8fe3e 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -1344,7 +1344,7 @@ limit stacksize unlimited ## This section was used to make Irrigated Tiles ##if(${MGRID} == M09 | ${MGRID} == M36) then ## bin/mkLandRaster.x -x ${NX} -y ${NY} -v -t ${NT} - ## bin/mkSMAPTilesPara_v2.x -ease_label ${MGRID} -pfaf_til T + ## bin/mkEASETilesParam.x -ease_label ${MGRID} -pfaf_til T ## bin/CombineRasters.x -f 0 -t 232000000 ${THISGRID} Pfafstetter > /dev/null ## bin/CombineRasters.x -t 232000000 ${THISGRID} ${THISGRID}-Pfafstetter ## /bin/mv til/${THISGRID}_${THISGRID}-Pfafstetter.til til/${THISGRID}_${THISGRID}-Pfafstetter.ind @@ -1353,8 +1353,8 @@ limit stacksize unlimited setenv MASKFILE ${MASKFILE} setenv OMP_NUM_THREADS 1 -# WY NOTE: the name mkSMAPTilesPara_v2.x will be changed to bin/bin/mkSMAPTilesPara.x -bin/mkSMAPTilesPara_v2.x -ease_label ${BCNAME} -v $lbcsv +bin/mkEASETilesParam.x -ease_label ${BCNAME} -v $lbcsv + setenv OMP_NUM_THREADS 1 bin/mkCatchParam.x -g ${BCNAME} -v $lbcsv -x ${NX} -y ${NY} setenv OMP_NUM_THREADS ${NCPUS} diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 similarity index 99% rename from GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 rename to GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 index 9f90710c9..e4217a151 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara_v2.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 @@ -1,6 +1,6 @@ #include "Raster.h" -PROGRAM mkSMAPTilesPara_v2 +PROGRAM mkEASETilesParam ! This program constructs land and lake tiles for EASE grid tile spaces such as ! those used for the SMAP Level-4 products and other offline projects @@ -9,6 +9,7 @@ PROGRAM mkSMAPTilesPara_v2 ! and mkSMAPTilesPara_v2.F90 in September 2022. ! Before the merger and cleanup, the EASE grid parameters were hard-coded here. ! For EASEv2 M25, the outdated scale value was used here. + ! This is program is renamed to mkEASETileParam from mkSMAPTilesPara_v2 ! ! - wjiang + reichle, 21 Sep 2022 @@ -77,7 +78,7 @@ PROGRAM mkSMAPTilesPara_v2 ! -------------------------------------------------------------------------------------- - usage1 = 'USAGE : bin/mkEASETiles -ease_label EASELabel -v LBCSV ' + usage1 = 'USAGE : bin/mkEASETilesParam.x -ease_label EASELabel -v LBCSV ' usage2 = ' where EASELabel = *EASEv[x]_M[yy]*, x={1,2}, yy={01,03,09,25,36}' N_args = command_argument_count() diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara.F90 deleted file mode 100644 index 7c938574d..000000000 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkSMAPTilesPara.F90 +++ /dev/null @@ -1,696 +0,0 @@ -PROGRAM mkSMAPTilesPara_v1 -! This program constructs land and lake tiles for the SMAP-EASE-M09 and M36 grids (just set MGRID) -! for CLSM implementation. -! f90 -c create_smap_tiles.f90 -! f90 -c smapconv.f -! f90 -o create_smap_tiles create_smap_tiles.o smapconv.o -! - use EASE_conv - use rmTinyCatchParaMod - use process_hres_data - use MAPL_SortMod - use MAPL_ConstantsMod - - implicit none - - integer i,j,ig,jg,i0,iop,n,d1,d2,j1,j2,i1,i2,ix, jx,icount,pcount - integer :: NC = i_raster, NR = j_raster, NT = 16330000, ND = 10000, ND_raster = 10000 - - integer, parameter :: nc_esa = 129600, nr_esa = 64800 - - ! For regridding - - integer, allocatable, target, dimension (:,:) & - :: geos_msk - REAL, allocatable, DIMENSION (:) :: loc_val - INTEGER, ALLOCATABLE, DIMENSION (:) :: density, loc_int - logical, dimension (:), allocatable :: unq_mask - integer, pointer , dimension (:,:) :: subset - integer, pointer , dimension (:) :: subset1, subset_smap - real, pointer , dimension (:) :: subset2 - integer :: dx_esa, dy_esa, NBINS, NPLUS - - integer*8, allocatable, dimension (:) :: SRTM_catid - - integer,allocatable, dimension (:,:), target :: tileid_index,catid_index - integer,allocatable, dimension (:,:) :: catid, iaster - integer,allocatable, dimension (:) :: land_id,water_id,ice_id - integer,allocatable, dimension (:) :: my_land, all_id - real, allocatable, dimension (:) :: smap_grid_area,tile_area,SRTM_CatchArea - integer*1,allocatable, dimension (:,:) :: veg, i2aster - real*4, dimension (:,:), allocatable :: q0,raster - REAL, dimension (:), allocatable :: tile_ele, tile_area_land - - INTEGER*8 :: PFAF_CODE - integer l,imn,imx,jmn,jmx,mval,l_index,i_index,w_index,typ,pfaf,cindex - integer :: LakeType, IceType, OceanType - character(3) :: easegrid - real :: clat, clon, r_smap, s_smap, smap_convert, da - real :: fr_gcm - integer :: ind_col, ind_row, status, ncid, nciv,nland_cells, DOM_INDX - REAL (kind=8), PARAMETER :: RADIUS=6378137.0,pi=3.14159265358979323846 - character*100 :: veg_class (12) - character*5 :: MGRID - character*100 :: gfile,gtopo30 - integer :: nc_smap,nr_smap, N_args, command_argument_count - real :: EASE_grid_area, CELL_km - REAL :: dx,dy,d2r,lats,mnx,mxx,mny,mxy,sum1,sum2,jgv, VDUM,pix_area - character(40) :: arg - character*200 :: tmpstring, tmpstring1, tmpstring2 - logical :: regrid = .false. - character*128 :: MaskFile - include 'netcdf.inc' - - N_args = command_argument_count() - - if(N_args < 1) then - print *,'USAGE : bin/mkSMAPTiles_v1 -smap_grid MXX' - print *,'Allowed SMAP grids are: M25' - stop - end if - - i=0 - - do while ( i < N_args ) - - i = i+1 - - call get_command_argument(i,arg) - - if ( trim(arg) == '-smap_grid' ) then - i = i+1 - call get_command_argument(i,MGRID) - - else ! stop for any other arguments - - print *,'USAGE : bin/mkSMAPTiles -smap_grid MXX' - print *,'Allowed SMAP grids are: M09 M36 Ml' - stop - - endif - - end do - - call execute_command_line('cd data/ ; ln -s /discover/nobackup/projects/gmao/ssd/land/l_data/LandBCs_files_for_mkCatchParam/V001/ CATCH') - call execute_command_line('cd ..') - - - ! Setting SMAP Grid specifications - ! -------------------------------- - - if (trim(MGRID) == 'M25') then - CELL_km = 25.067525 ! nominal cell size in kilometers - nc_smap = 1383 - nr_smap = 586 - gfile = 'SMAP_EASE_M25_1383x586' - EASE_grid_area = CELL_km*CELL_km - - else ! - - print *,'Unknown SMAP Grid stopping..' - stop - - endif - - allocate(land_id (1:NT)) - allocate(water_id (1:NT)) - allocate(ice_id (1:NT)) - land_id = 0 - water_id = 0 - ice_id = 0 - OceanType = 0 - IceType =11 - LakeType =10 - - ND = 10*10**(nint(log10(1.*nr_smap))) - - ! Check for the 10 arc-sec MaskFile - ! ----------------------------------- - - call get_environment_variable ("MASKFILE" ,MaskFile ) - - print *, 'Using MaskFile ', trim(MaskFile) - - if (index(MaskFile,'GEOS5_10arcsec_mask') /= 0) then - ! New ESA (Veg) + SRTM (catchments) based mask file - ! is overlaid on SMAP - ! ------------------------------------------------- - - nc = 43200 ! Number of rows in raster file - nr = 21600 ! Number of columns in raster file - - regrid = .true. - dx_esa = nc_esa / nc ! x-dimension (or # of ESA columns within the raster grid cell) - dy_esa = nr_esa / nr ! y-dimension (or # of ESA rows within the raster grid cell) - - allocate(tileid_index(1:nc,1:nr)) - allocate(SRTM_catid (1:SRTM_maxcat+2)) - allocate(catid_index (1:nc,1:nr)) - allocate(veg (1:nc,1:nr)) - allocate(geos_msk (1:nc_esa,1:dy_esa)) - allocate(SRTM_CatchArea (1:SRTM_maxcat)) - - OPEN (10, FILE = 'data/CATCH/SRTM-TopoData/Pfafcatch-routing.dat', & - FORM = 'FORMATTED',STATUS='OLD',ACTION='READ') - - READ (10,*) I - DO N = 1, I - READ (10, '(i8,i15,4(1x,f9.4),1x,e10.3,4(1x,e9.3),I8,6(1x,f9.4))') & - DOM_INDX,PFAF_CODE,VDUM,VDUM,VDUM,VDUM,VDUM, & - SRTM_CatchArea (N) - END DO - CLOSE (10, STATUS='KEEP') - - dx = 360._8/nc - dy = 180._8/nr - d2r = PI/180._8 - da = MAPL_radius*MAPL_radius*pi*pi*dx*dy/180./180./1000000. - - tileid_index = 0 - catid_index = 0 - veg = 0 - - status = NF_OPEN ('data/CATCH/GEOS5_10arcsec_mask.nc', NF_NOWRITE, ncid) - status = NF_GET_VARA_INT64 (ncid,3,(/1/),(/SRTM_maxcat/),SRTM_catid(1:SRTM_maxcat)) ! Read pfafstetter IDs - if(status /=0) then - PRINT *, NF_STRERROR(STATUS) - print *, 'Problem with NF_OPEN',trim(MaskFile) - endif - - SRTM_catid (SRTM_maxcat + 1) = 190000000 - SRTM_catid (SRTM_maxcat + 2) = 200000000 - i1 = 0 ! count # of 30-arcsec pixels - - do j=1,nr - - clat = -90. + float(j-1)*dy + dy/2. - - status = NF_GET_VARA_INT (ncid,4,(/1,(j-1)*dy_esa +1/),(/nc_esa,dy_esa/),geos_msk) ! Read 10-arcsec rows that lie within the raster row 'j' - - if(status /=0) then - PRINT *, NF_STRERROR(STATUS) - print *, 'Problem with NF_GET_VARA_INT',trim(MaskFile),status - endif - - do i = 1,nc - - clon = -180. + float(i-1)*dx + dx/2. - - if (associated (subset)) NULLIFY (subset) - subset => geos_msk ((i-1)*dx_esa + 1 : i*dx_esa, 1:dy_esa) ! rectangular array contains ESA pixels that lie within the raster grid cell at i,j - if(maxval (subset) > SRTM_maxcat) then - where (subset == 190000000) subset = SRTM_maxcat + 1 - where (subset == 200000000) subset = SRTM_maxcat + 2 - endif - - if (maxval (subset) > 0) then ! check whether there are Non-ocean ESA pixels - ! catID of the middle pixel - - veg (i,j) = 1 ! veg is set to land - - NPLUS = count(subset >= 1 .and. subset <= SRTM_maxcat + 2) ! Count non-ocean ESA pixels within - allocate (loc_int (1:NPLUS)) - allocate (unq_mask(1:NPLUS)) - loc_int = pack(subset,mask = (subset >= 1 .and. subset <= SRTM_maxcat + 2)) ! loc_int contains catch_indices of non-ocean ESA pixels - call MAPL_Sort (loc_int) - unq_mask = .true. - do n = 2,NPLUS - unq_mask(n) = .not.(loc_int(n) == loc_int(n-1)) ! count number of unique numbers in loc_int for binning - end do - NBINS = count(unq_mask) - - if (NBINS > 1) then - allocate(loc_val (1:NBINS)) - allocate(density (1:NBINS)) - loc_val = 1.*pack(loc_int,mask =unq_mask) ! loc_val contains available non-ocean catch_indices within the i,j grid cell, - ! Those numbers will be used as bin values - call histogram (dx_esa*dy_esa, NBINS, density, loc_val, real(subset)) ! density is the pixel count for each bin value - catid_index (i,j) = loc_val (maxloc(density,1)) ! picks maximum density as the dominant catchment_index at i,j - deallocate (loc_val, density) - else - catid_index (i,j) = loc_int (1) - endif - deallocate (loc_int, unq_mask) - - if(catid_index (i,j) == SRTM_maxcat + 1) veg (i,j) = LakeType - if(catid_index (i,j) == SRTM_maxcat + 2) veg (i,j) = IceType - if((catid_index(i,j) >= 1).and.(catid_index (i,j) <= SRTM_maxcat)) i1 = i1 + 1 - - ! count in if this is i,j pixel is a land, lake or ice within ind_col,ind_row SMAP grid cell - - call easeV1_convert(trim(MGRID), clat, clon, r_smap, s_smap) - - ind_col = nint(r_smap) + 1 - ind_row = nint(s_smap) + 1 - - if((ind_row.ge.1).and.(veg(i,j).ne.OceanType).and.(ind_row.le.nr_smap)) then - l= ind_row*ND + ind_col - - if(veg(i,j)==LakeType) then - water_id(l) = 1 - else if(veg(i,j)==IceType) then - ice_id (l) = 1 - else - land_id (l) = 1 - endif - endif - endif - end do - enddo - - status = NF_CLOSE (ncid) - deallocate (geos_msk) - - print *,'Read ', trim (MaskFile) - print *,'Min and Max of tile indices:',minval(catid_index),maxval(catid_index) - - else - - ! Old IGBP (Veg) + HYDRO1k (catchments) based mask will - ! Overlaid on SMAP mask - ! ----------------------------------------------------- - - allocate(iaster (i_raster,j_raster)) - allocate(i2aster (i_raster,j_raster)) - allocate(veg (1:nc,1:nr)) - allocate(catid (1:nc,1:nr)) - allocate(catid_index (1:nc,1:nr)) - allocate(tileid_index(1:nc,1:nr)) - - dx = 360._8/nc - dy = 180._8/nr - d2r = PI/180._8 - da = MAPL_radius*MAPL_radius*pi*pi*dx*dy/180./180./1000000. - - tileid_index = 0 - - ! Simple Biosphere 2 Model Legend - ! Value Class Name - ! (ftp://edcftp.cr.usgs.gov/pub/data/glcc/globe/latlon/sib22_0.leg) - ! the types vary 0-11 (array index minus 1) - - veg_class(1) = 'Ocean' - veg_class(2) = 'Broadleaf Evergreen Trees' - veg_class(3) = 'Broadleaf Deciduous Trees' - veg_class(4) = 'Broadleaf and Needleleaf Trees' - veg_class(5) = 'Needleleaf Evergreen Trees' - veg_class(6) = 'Needleleaf Deciduous Trees' - veg_class(7) = 'Short Vegetation/C4 Grassland' - veg_class(8) = 'Shrubs with Bare Soil' - veg_class(9) = 'Dwarf Trees and Shrubs' - veg_class(10) = 'Agriculture or C3 Grassland' - veg_class(11) = 'Water, Wetlands' - veg_class(12) = 'Ice/Snow' - - ! reading SiB2 land cover classification data - the origin of the - ! 2.5'x2.5' vegetation raster file is global 1min IGBP data - ! (ftp://edcftp.cr.usgs.gov/pub/data/glcc/globe/latlon/sib22_0.leg) - - open (10,file='data/CATCH/sib22.5_v2.0.dat', & - form='unformatted', & - action='read', convert='big_endian',status='old') - - READ(10)i2aster - - close (10,status='keep') - - if(regrid) then - call RegridRaster1 (i2aster,veg) - else - veg = i2aster - endif - - deallocate (i2aster) - - ! reading 2.5'x2.5' global raster file of Pfafstetter Catchment IDs - ! In this version, the dateline has been overlaid over the catchments those straddle - ! across. The numbers contain for - ! 1 global ocean catchment : Pfafstetter ID 0 - ! 36716 global land catchments : Pfafstetter IDs 1000-5999900 - ! 1 global inland water (lakes) catchment : Pfafstetter ID 6190000 - ! 1 global ice catchment : Pfafstetter ID 6200000 - - open (10,file='data/CATCH/global.cat_id.catch.DL', form='formatted', & - action='read', status='old')! - - do j=1,j_raster - read(10,*)(iaster(i,j),i=1,i_raster) - end do - - close (10,status='keep') - - if(regrid) then - call RegridRaster(iaster,catid) - else - catid = iaster - endif - - print *,'Read global.cat_id.catch.DL' - print *,'Min and Max of Pfafstetter IDs:', minval(catid),maxval(catid) - - ! reading the 2.5'x2.5' global raster file of tile indices for the - ! above Pfafstetter Catchments - ! 1 global ocean catchment : tile_index 36719 - ! 36716 global land catchments : tile_index 1-36716 - ! 1 global inland water (lakes) catchment : tile_index 36717 - ! 1 global ice catchment : tile_index 36718 - ! ------------------------------------------------------------ - - open (10,file='data/CATCH/' & - //'PfafstatterDL.rst', form='unformatted', & - action='read',convert='little_endian', status='old') - - do j=1,j_raster - read(10)(iaster(i,j),i=1,i_raster) - end do - - close (10,status='keep') - - if(regrid) then - call RegridRaster(iaster,catid_index) - else - catid_index = iaster - endif - - deallocate (iaster) - - print *,'Read PfafstatterDL.rst' - print *,'Min and Max of tile indices:',minval(catid_index),maxval(catid_index) - - ! While looping through the nc x nr grid (tile raster), this section counts # of - ! SMAP grid cells that contain land, ice or water, seperately. - ! Each SMAP grid cell is assigned with an ID = ind_row*ND + ind_col. - ! This is just the prelimiminery assessment in the process of assigning separate - ! tiles for land, water and ice fractions within the SMAP Grid cell - ! The program checks each nc x nr pixels whether there is a SMAP grid cell underneath, and counts - ! number of water, land and ice pixels as seen on veg raster. - ! ----------------------------------------------------------------------------------------------- - - - do i = 1 ,nc - - clon = -180. + float(i-1)*dx + dx/2. - - do j =nr ,1 ,-1 - - clat = -90. + float(j-1)*dy + dy/2. - call easeV1_convert(trim(MGRID), clat, clon, r_smap, s_smap) - - ind_col = nint(r_smap) + 1 - ind_row = nint(s_smap) + 1 - - if((ind_row.ge.1).and.(veg(i,j).ne.OceanType).and.(ind_row.le.nr_smap)) then - l= ind_row*ND + ind_col - - if(veg(i,j)==LakeType) then - water_id(l) = 1 - else if(veg(i,j)==IceType) then - ice_id (l) = 1 - else - land_id (l) = 1 - endif - endif - end do - end do - - endif - - ! Reading SRTM elevation data - to be consistent with AGCM - ! -------------------------------------------------------- - - allocate(raster (i_raster,j_raster)) - allocate(q0(nc,nr)) - - gtopo30 = 'data/CATCH/srtm30_withKMS_2.5x2.5min.data' - - open (10,file=trim(gtopo30),form='unformatted',status='old',convert='little_endian') - read (10) raster - close (10,status='keep') - - if(regrid) then - call RegridRasterReal(raster,q0) - else - q0 = raster - endif - - deallocate (raster) - - print *,'# of Land pixels in SMAP: ',sum (land_id) - print *,'# of water pixels in SMAP: ',sum (water_id) - print *,'# of ice pixels in SMAP: ',sum (ice_id) - - l_index=0 - w_index=sum (land_id) - i_index=sum (land_id) + sum (water_id) - nland_cells = w_index - - - allocate(tile_area (1:i_index + sum (ice_id))) - allocate(smap_grid_area (1:NT)) - allocate(tile_ele (1:w_index)) - allocate(tile_area_land(1:w_index)) - allocate(my_land (1:i_index + sum (ice_id))) - allocate(all_id (1:i_index + sum (ice_id))) - - land_id = 0 - water_id= 0 - ice_id = 0 - - my_land = 0 - all_id = 0 - smap_grid_area = 0. - tile_area_land = 0. - tile_ele = 0. - tile_area = 0. - - ! While looping through the nc x nr grid, this section derives land, ice and water tiles. - ! Each SMAP grid cell is assigned with an ID = ind_row*ND + ind_col - ! ind_col, ind_row are overlying SMAP grid cell indices - ! Based on the above sums: - ! l_index Grid cells have land fractions (sum(land_id)) - ! w_index SMAP Grid cells have inland water fractions (sum(water_id)) - ! i_index SMAP Grid cells have ice fractions (sum(ice_id)) - ! hence, tile_index 1 to l_index represent land tiles - ! tile_index l_index +1 to l_index + w_index represent water (lakes) tiles - ! tile_index l_index + w_index +1 to l_index + w_index + i_index represent ice tiles - ! global nc x nr array of tileid_index(nc,nr) contains corresponding tile_index values which - ! is derived in the below loop - - ND_raster = 10*10**(nint(log10(1.*NR))) - i2 = 1 - - do i = 1 ,nc - - clon = -180. + float(i-1)*dx + dx/2. - - do j =nr ,1 ,-1 - lats = -90._8 + (j - 0.5_8)*dy - clat = -90. + float(j-1)*dy + dy/2. - call easeV1_convert(trim(MGRID), clat, clon, r_smap, s_smap) - - ind_col = nint(r_smap) + 1 - ind_row = nint(s_smap) + 1 - - l= ind_row*ND + ind_col - pix_area =(sin(d2r*(lats+0.5*dy)) -sin(d2r*(lats-0.5*dy)))*(dx*d2r) - - if((ind_row.ge.1).and.(veg(i,j).ge.1).and.(ind_row.le.nr_smap)) then - - if(veg(i,j)==LakeType) then - if(water_id(l)==0) then - w_index = w_index + 1 - water_id(l) = w_index - tileid_index(i,j)= water_id(l) - else - tileid_index(i,j)= water_id(l) - endif - endif - - if(veg(i,j)==IceType) then - if(ice_id(l)==0) then - i_index = i_index + 1 - ice_id (l) = i_index - tileid_index(i,j)= ice_id (l) !i_index - else - tileid_index(i,j)= ice_id (l) !i_index - endif - endif - - if(veg(i,j).lt.LakeType) then - if(land_id(l)==0) then - l_index = l_index + 1 - land_id (l) = l_index - tileid_index(i,j)= land_id (l) !1-l_index - else - tileid_index(i,j)= land_id (l) !1-l_index - endif - - endif - tile_area(tileid_index(i,j))= tile_area(tileid_index(i,j)) + & - pix_area - my_land(tileid_index(i,j)) = l - all_id (tileid_index(i,j)) = j*ND_raster + i - endif - - if((ind_row.ge.1).and.(ind_row.le.nr_smap)) then - smap_grid_area(l) = smap_grid_area(l) + & - pix_area - endif - - ! computing tile area/elevation - ! ----------------------------- - - if((tileid_index(i,j) > 0).and.(tileid_index(i,j) <= nland_cells))then - tile_ele(tileid_index(i,j)) = tile_ele(tileid_index(i,j)) + q0(i,j) * & - pix_area - tile_area_land(tileid_index(i,j)) = tile_area_land(tileid_index(i,j)) + & - pix_area - endif - end do - end do - - deallocate(land_id, q0) - deallocate(water_id) - deallocate(ice_id ) - - tile_ele = tile_ele/tile_area_land - - ! adjustment Global Mean Topography to 614.649 (615.662 GTOPO 30) m - ! ----------------------------------------------------------------- - sum1=0. - sum2=0. - - do j=1,l_index - sum1 = sum1 + tile_ele(j)*tile_area(j) - enddo - - if(sum1/sum(tile_area(1:l_index)).ne. 614.649D0 ) then - print *,'Global Mean Elevation (over land): ', sum1/sum(tile_area(1:l_index)) - tile_ele =tile_ele*(614.649D0 / (sum1/sum(tile_area(1:l_index)))) - sum1=0. - sum2=0. - do j=1,l_index - sum1 = sum1 + tile_ele(j)*tile_area(j) - enddo - print *,'Global Mean Elevation after scaling to SRTM : ',sum1/sum(tile_area(1:l_index)) - endif - print *,'Total Land Area :', sum(tile_area(1:l_index))* MAPL_RADIUS * MAPL_RADIUS/1000./1000., & - sum(tile_area_land(1:l_index))* MAPL_RADIUS * MAPL_RADIUS/1000./1000. - - print *,'Creating ... ', trim(gfile)//'rst' - - !------------------------------------------- - - open (10, file ='rst/'//trim(gfile)//'.rst',form='unformatted',status='unknown', & - action='write') - - do j=1,nr - write(10)(tileid_index(i,j),i=1,nc) - end do - - close (10,status='keep') - - print *,'Creating ... ', trim(gfile)//'til ,catchment.def' - - !----------------------------------------------------------- - - open (11,file='clsm/catchment.def', & - form='formatted',status='unknown') - write(11,*)l_index - - open (10, file ='til/'//trim(gfile)//'.til',form='formatted',status='unknown',action='write') - write (10,*)i_index, SRTM_maxcat, nc, nr - write (10,*)1 - write (10,*)'SMAP-EASEv2-'//trim(MGRID) - write (10,*)nc_smap - write (10,*)nr_smap -! write (10,*)'NO-OCEAN' -! write (10,*) -9999 -! write (10,*) -9999 - - do l=1,i_index - - ig = my_land(l)-ND*(my_land(l)/ND) - jg = my_land(l)/ND - - cindex= catid_index(all_id(l)-ND_raster*(all_id(l)/ND_raster),all_id(l)/ND_raster) - - if (index(MaskFile,'GEOS5_10arcsec_mask') /= 0) then - pfaf = cindex - else - pfaf = catid(all_id(l)-ND_raster*(all_id(l)/ND_raster),all_id(l)/ND_raster) - endif - - if ((l > l_index).and.(l <= w_index)) typ =19 - if (l > w_index) typ = 20 - - if (l <= l_index) then - typ = 100 - call easeV1_inverse (trim(MGRID), real(ig-1),real(jg-1), clat, clon) - - mnx = clon - 180./real(nc_smap) - mxx = clon + 180./real(nc_smap) - - jgv = real(jg-1) + 0.5 - - call easeV1_inverse (trim(MGRID), real(ig-1),jgv, clat, clon) - - mny = clat - - jgv = real(jg-1) - 0.5 - - call easeV1_inverse (trim(MGRID), real(ig-1),jgv, clat, clon) - - mxy = clat - - write (11,'(i8,i8,5(2x,f9.4), i4)')l,pfaf,mnx,mxx,mny,mxy,tile_ele(l) - - endif - - call easeV1_inverse (trim(MGRID), real(ig-1), real(jg-1), clat, clon) - - fr_gcm= tile_area(l)/smap_grid_area(jg*ND + ig) - - if (index(MaskFile,'GEOS5_10arcsec_mask') /= 0) then - write(10,'(i10,i9,2f10.4,2i5,f19.12,i10,i15,e13.4)') & - typ,pfaf,clon,clat,ig-1,jg-1,fr_gcm ,pfaf,SRTM_catid(cindex) - else - write(10,'(i10,i9,2f10.4,2i5,f19.12,i10,e13.4,i8)') & - typ,pfaf,clon,clat,ig-1,jg-1,fr_gcm ,cindex - endif - - end do - - close (10,status='keep') - close (11,status='keep') - - deallocate (tileid_index,catid_index,veg) - deallocate (tile_area, smap_grid_area, tile_ele, tile_area_land, my_land, all_id) - - if (index(MaskFile,'GEOS5_10arcsec_mask') /= 0) then - - print *,'Creating SMAP-Catch_TransferData.nc files.' - - !--------------------------------------------------- - - deallocate (SRTM_CatchArea, SRTM_catid) - - endif - - ! create Grid2Catch transfer file - ! ------------------------------- - - ! CALL CREATE_ROUT_PARA_FILE (NC, NR, trim(gfile), MGRID=MGRID) - - ! now run mkCatchParam - ! -------------------- - - tmpstring1 = '-e EASE -g '//trim(gfile) - write(tmpstring2,'(2(a2,x,i5,x))')'-x',nc,'-y',nr - tmpstring = 'bin/mkCatchParam.x '//trim(tmpstring2)//' '//trim(tmpstring1) - print *,trim(tmpstring) - - call execute_command_line (tmpstring) - - END PROGRAM mkSMAPTilesPara_v1 - From 6b8fe5c19db3bf8ce9477819434ffed77c4281e1 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Tue, 27 Sep 2022 15:56:21 -0400 Subject: [PATCH 40/77] add area argument to ease_extent --- .../GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 index df9c26ea1..3fa7746d1 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 @@ -225,10 +225,11 @@ end subroutine ease_inverse ! ******************************************************************* - subroutine ease_extent (EASELabel, cols, rows ) + subroutine ease_extent (EASELabel, cols, rows, CELL_area ) - character*(*), intent(in) :: EASELabel - integer, intent(out) :: cols, rows + character*(*), intent(in) :: EASELabel + integer, intent(out) :: cols, rows + real, optional, intent(out):: CELL_area real*8 :: map_scale_m, CELL_km, r0, s0, Rg character(3) :: grid @@ -250,8 +251,10 @@ subroutine ease_extent (EASELabel, cols, rows ) if( index(EASELabel,'EASEv2') /=0) then call easeV2_get_params(grid, map_scale_m, cols, rows, r0, s0) + if(present(CELL_area)) CELL_area = map_scale_m**2 / 1000.0 / 1000.0 else if(index(EASELabel,'EASEv1') /=0) then call easeV1_get_params(grid, CELL_km, cols, rows, r0, s0, Rg) + if(present(CELL_area)) CELL_area = Cell_km**2 else print*,"ease_extent(): unknown grid version: "//trim(EASELabel)//" STOPPING." stop From 509e11ac9a07b636750c0495ac8b11000a777678 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 29 Sep 2022 09:22:13 -0400 Subject: [PATCH 41/77] add default init_bcs values when lbcsv is undefined --- .../GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 | 2 +- .../Utils/Raster/rmTinyCatchParaMod.F90 | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 index 3fa7746d1..dc21a61dd 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 @@ -229,7 +229,7 @@ subroutine ease_extent (EASELabel, cols, rows, CELL_area ) character*(*), intent(in) :: EASELabel integer, intent(out) :: cols, rows - real, optional, intent(out):: CELL_area + real, optional, intent(out) :: CELL_area real*8 :: map_scale_m, CELL_km, r0, s0, Rg character(3) :: grid diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index 992bb7310..fdb2041a1 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -167,7 +167,14 @@ SUBROUTINE init_bcs_config (LBCSV) GNU = 1.0 use_PEATMAP = .false. jpl_height = .false. - + + case ("UNDEF") + LAIBCS = 'MODGEO' + SOILBCS = 'HWSD' + MODALB = 'MODIS2' + GNU = 1.0 + use_PEATMAP = .true. + jpl_height = .true. end select END SUBROUTINE init_bcs_config From 8b5045973503d7a406c567b6e9be093c1bf40e5a Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 29 Sep 2022 12:10:37 -0400 Subject: [PATCH 42/77] remove overiding lbcsv for EASEv1 --- .../GEOSsurface_GridComp/Utils/Raster/make_bcs | 6 +----- .../Utils/Raster/mkEASETilesParam.F90 | 12 ++++++------ .../Utils/Raster/rmTinyCatchParaMod.F90 | 9 +-------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index 5b9a8fe3e..7c56ba20c 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -1286,10 +1286,6 @@ if( $grid == ease ) then #else # set EASEVERSION = EASEv2 #endif - if ( $EASEVERSION == EASEv1 ) then - ## for easev1, default values - set lbcsv = UNDEF - endif set RS = ${im}x${jm} set IM = `echo ${im} | awk '{printf "%4.4i", $1}'` @@ -1353,7 +1349,7 @@ limit stacksize unlimited setenv MASKFILE ${MASKFILE} setenv OMP_NUM_THREADS 1 -bin/mkEASETilesParam.x -ease_label ${BCNAME} -v $lbcsv +bin/mkEASETilesParam.x -ease_label ${BCNAME} setenv OMP_NUM_THREADS 1 bin/mkCatchParam.x -g ${BCNAME} -v $lbcsv -x ${NX} -y ${NY} diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 index e4217a151..943cad660 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 @@ -15,7 +15,8 @@ PROGRAM mkEASETilesParam use EASE_conv - use rmTinyCatchParaMod + use rmTinyCatchParaMod, only : i_raster, j_raster, SRTM_maxcat + use rmTinyCatchParaMod, only : RegridRaster, RegridRaster1, RegridRasterReal use process_hres_data use MAPL_SortMod use MAPL_ConstantsMod @@ -23,7 +24,6 @@ PROGRAM mkEASETilesParam use netcdf implicit none - character*5 :: LBCSV = 'UNDEF' integer i,j,ig,jg,i0,iop,n,d1,d2,j1,j2,i1,i2,ix, jx,icount,pcount integer :: NC = i_raster, NR = j_raster, NT = 16330000, ND = 10000, ND_raster = 10000 @@ -78,7 +78,7 @@ PROGRAM mkEASETilesParam ! -------------------------------------------------------------------------------------- - usage1 = 'USAGE : bin/mkEASETilesParam.x -ease_label EASELabel -v LBCSV ' + usage1 = 'USAGE : bin/mkEASETilesParam.x -ease_label EASELabel ' usage2 = ' where EASELabel = *EASEv[x]_M[yy]*, x={1,2}, yy={01,03,09,25,36}' N_args = command_argument_count() @@ -106,9 +106,9 @@ PROGRAM mkEASETilesParam ! call get_command_argument(i,PF) ! if (PF == 'T') pfaf_til = .true. - elseif ( trim(arg) == '-v' ) then - i = i+1 - call get_command_argument(i,LBCSV) + !elseif ( trim(arg) == '-v' ) then + ! i = i+1 + ! call get_command_argument(i,LBCSV) else ! stop for any other arguments print *,trim(usage1) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index fdb2041a1..992bb7310 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -167,14 +167,7 @@ SUBROUTINE init_bcs_config (LBCSV) GNU = 1.0 use_PEATMAP = .false. jpl_height = .false. - - case ("UNDEF") - LAIBCS = 'MODGEO' - SOILBCS = 'HWSD' - MODALB = 'MODIS2' - GNU = 1.0 - use_PEATMAP = .true. - jpl_height = .true. + end select END SUBROUTINE init_bcs_config From b95e6bea020848a3c1224da340e331ad00ebd593 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Thu, 29 Sep 2022 18:01:26 -0400 Subject: [PATCH 43/77] =?UTF-8?q?Additional=20bug=20fixes=20and=20clean-up?= =?UTF-8?q?=20in=20make=5Fbcs=20package:=20-=20EASE=5Fconv.F90=20=20=20-?= =?UTF-8?q?=20added=20optional=20args=20for=20grid=20cell=20boundary=20cor?= =?UTF-8?q?ner=20lat/lon=20to=20ease=5Fextent()=20=20=20-=20switched=20uni?= =?UTF-8?q?ts=20of=20cell=5Farea=20to=20[m]=20-=20make=5Fbcs=20=20=20-=20f?= =?UTF-8?q?ixed=20IM,=20JM=20look-up=20table=20for=20EASEv1=20and=20EASEv2?= =?UTF-8?q?=20(bug=20fix)=20=20=20-=20use=20standard=203-char=20string=20f?= =?UTF-8?q?or=20EASE=20grid=20names=20in=20HRCODE=20=20=20-=20replaced=20u?= =?UTF-8?q?nnecessary=20EASE-specific=20variable=20MGRID=20with=20existing?= =?UTF-8?q?=20variable=20HRCODE=20=20=20-=20made=20all=20input=20queries?= =?UTF-8?q?=20case-sensitive=20=20=20-=20simplified=20if=20statements=20fo?= =?UTF-8?q?r=20help=20messages=20and=20queries=20=20=20-=20separated=20out?= =?UTF-8?q?=20query=20for=20EASE=20grid=20version=20-=20rmTinyCatchParam.F?= =?UTF-8?q?90=20=20=20-=20added=20missing=20=E2=80=9Ccase=20default?= =?UTF-8?q?=E2=80=9D=20in=20init=5Fbcs=5Fconfig()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Utils/Raster/EASE_conv.F90 | 40 ++- .../Utils/Raster/make_bcs | 315 ++++++++++-------- .../Utils/Raster/mkEASETilesParam.F90 | 4 - .../Utils/Raster/rmTinyCatchParaMod.F90 | 5 + 4 files changed, 214 insertions(+), 150 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 index dc21a61dd..7d02a9065 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 @@ -225,13 +225,22 @@ end subroutine ease_inverse ! ******************************************************************* - subroutine ease_extent (EASELabel, cols, rows, CELL_area ) + subroutine ease_extent (EASELabel, cols, rows, cell_area, ll_lon, ll_lat, ur_lon, ur_lat) + + ! get commonly used EASE grid parameters + + character*(*), intent(in) :: EASELabel + integer, intent(out) :: cols, rows ! number of grid cells in lon and lat direction + real, optional, intent(out) :: cell_area ! [m] + real, optional, intent(out) :: ll_lon ! lon of grid cell boundary in lower left corner + real, optional, intent(out) :: ll_lat ! lat of grid cell boundary in lower left corner + real, optional, intent(out) :: ur_lon ! lon of grid cell boundary in upper right corner + real, optional, intent(out) :: ur_lat ! lat of grid cell boundary in upper right corner - character*(*), intent(in) :: EASELabel - integer, intent(out) :: cols, rows - real, optional, intent(out) :: CELL_area + ! --------------------------------------------------------------------- real*8 :: map_scale_m, CELL_km, r0, s0, Rg + real :: tmplon character(3) :: grid if ( index(EASELabel,'M36') /=0 ) then @@ -250,18 +259,35 @@ subroutine ease_extent (EASELabel, cols, rows, CELL_area ) endif if( index(EASELabel,'EASEv2') /=0) then + call easeV2_get_params(grid, map_scale_m, cols, rows, r0, s0) - if(present(CELL_area)) CELL_area = map_scale_m**2 / 1000.0 / 1000.0 + + if(present(cell_area)) cell_area = map_scale_m**2 + else if(index(EASELabel,'EASEv1') /=0) then + call easeV1_get_params(grid, CELL_km, cols, rows, r0, s0, Rg) - if(present(CELL_area)) CELL_area = Cell_km**2 + + if(present(cell_area)) cell_area = CELL_km**2 * 1000. * 1000. + else + print*,"ease_extent(): unknown grid version: "//trim(EASELabel)//" STOPPING." stop + endif + + ! get lat/lon of corner grid cells + ! + ! recall that EASE grid indexing is zero-based + + if (present(ll_lat)) call ease_inverse(EASElabel, 0., rows-0.5, ll_lat, tmplon) + if (present(ur_lat)) call ease_inverse(EASElabel, 0., -0.5, ur_lat, tmplon) + if (present(ll_lon)) ll_lon = -180. + if (present(ur_lon)) ur_lon = 180. + end subroutine ease_extent - ! ******************************************************************* ! diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index 7c56ba20c..c7e520c9d 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -9,7 +9,7 @@ if ( "$1" == "-h" | "$1" == "-help" | "$1" == "--help" ) set HELPMODE = YES if ( $HELPMODE == YES ) then - echo "Usage: `basename $0` [option] " + echo "Usage: `basename $0` [-h] " echo " " echo "Boundary Conditions (BCs) Package: " echo " Creates surface tile and other model parameter input files " @@ -24,8 +24,9 @@ if ( $HELPMODE == YES ) then echo " Answer the following interactive questions: " echo " a) Select Land BCs version. " echo " b) Select atmospheric resolution(s). " + echo " (If applicable, select EASE grid version.) " echo " c) Select ocean resolution(s). " - echo " (Not relevant for land-only EASE-grid BCs.) " + echo " (Not relevant for land-only EASE grid BCs.) " echo " d) Enter BCs output directory. " echo " e) Enter sponsor code for computing account. " echo " " @@ -96,14 +97,11 @@ if ( $HELPMODE != YES ) then echo "----------------------------------------------------------------------------------------------" echo " Boundary Conditions (BCs) Package:" echo "----------------------------------------------------------------------------------------------" - echo " " - echo "Enter 3-character alphanumeric code for land BCs version:" - echo "(Select only one.)" - echo " " -else - echo "Options for land BCs version:" endif - + +echo " " +echo "Options for land BCs version:" +echo " " echo " ${C2}F25 = Fortuna-2_5 (archived${CR}${C1}*${CR}${C2}: n/a)${CR}" echo " ${C2}GM4 = Ganymed-4_0 (archived${CR}${C1}*${CR}${C2}: /discover/nobackup/ltakacs/bcs/Ganymed-4_0/)${CR}" echo " ${C2}ICA = Icarus (archived${CR}${C1}*${CR}${C2}: /discover/nobackup/ltakacs/bcs/Icarus/)${CR}" @@ -124,16 +122,13 @@ if ( $HELPMODE != YES ) then echo " science is insignificant, and the parameter files produced by current" echo " code are scientifically equivalent to the corresponding archived BCs." echo " " - echo " OR press ENTER to select $lbcsv (current default).${CR}" + echo " Enter one 3-character alphanumeric code for land BCs version from the above list" + echo " OR press ENTER to select $lbcsv (current default):${CR}" echo " " -endif - -LBCSV: -if ( $HELPMODE != YES ) then + LBCSV: set dummy = `echo $<` - if( $dummy == 'F25' | \ $dummy == 'GM4' | \ $dummy == 'ICA' | \ @@ -148,7 +143,7 @@ if ( $HELPMODE != YES ) then echo $lbcsv else echo " " - echo " ${C1} Invalid choice, try again:${CR}" + echo " ${C1} Invalid choice. Note that entry is case-sensitive. Try again:${CR}" goto LBCSV endif @@ -158,19 +153,14 @@ endif # # Atmospheric Horizontal Resolution (HRCODE) -if ( $HELPMODE != YES ) then - echo " " - echo "Enter 1-5 character alphanumeric code(s) for atmospheric horizontal resolution:" - echo "(Separate multiple entries by spaces.)" -else - echo "Options for atmospheric horizontal resolution:" -endif +echo "Options for atmospheric horizontal resolution:" +echo " " echo " Lat/Lon Cubed-Sphere EASE (land-only)" -echo " ${C2}b -- 2 deg c12 -- 8 deg m1 -- 1km EASEv2 Grid ${CR}" -echo " ${C2}c -- 1 deg c24 -- 4 deg m3 -- 3km EASEv2 Grid ${CR}" -echo " ${C2}d -- 1/2 deg c48 -- 2 deg m9 -- 9km EASEv2 Grid ${CR}" -echo " ${C2}e -- 1/4 deg c90 -- 1 deg m36 -- 36km EASEv2 Grid ${CR}" -echo " ${C2} c180 -- 1/2 deg ${C1}( 56 km) ${CR} ${C2}m25 -- 25km EASEv1 Grid ${CR}" +echo " ${C2}b -- 2 deg c12 -- 8 deg M01 -- 1-km EASE Grid ${CR}" +echo " ${C2}c -- 1 deg c24 -- 4 deg M03 -- 3-km EASE Grid ${CR}" +echo " ${C2}d -- 1/2 deg c48 -- 2 deg M09 -- 9-km EASE Grid ${CR}" +echo " ${C2}e -- 1/4 deg c90 -- 1 deg M25 -- 25-km EASE Grid ${CR}" +echo " ${C2} c180 -- 1/2 deg ${C1}( 56 km) ${CR} ${C2}M36 -- 36-km EASE Grid ${CR}" echo " ${C2} c360 -- 1/4 deg ${C1}( 28 km) ${CR}" echo " ${C2} c720 -- 1/8 deg ${C1}( 14 km) ${CR}" echo " ${C2} c768 -- 1/10 deg ${C1}( 12 km) ${CR}" @@ -182,15 +172,18 @@ echo " ${C2} c2880 -- 1/32 deg ${C1}( 3 km) ${CR}" echo " ${C2} c3072 -- 1/32 deg ${C1}( 3 km) ${CR}" echo " ${C2} c5760 -- 1/64 deg ${C1}( 1.5 km) ${CR}" #echo " ${C2}o -- other${CR} Lat/Lon or Cube" -echo " " +echo " " -HRCODE: if ( $HELPMODE != YES ) then + echo " " + echo "Enter alphanumeric code(s) for atmospheric horizontal resolution from the above list" + echo "(separate multiple entries by spaces):" + + HRCODE: set dummy = `echo $<` if (${%dummy} == 0) set dummy = "BLANK" - set dummy = `echo $dummy | tr "[:upper:]" "[:lower:]"` set HRCODES = $dummy[1] foreach HRCODE ($dummy) @@ -214,12 +207,12 @@ if ( $HELPMODE != YES ) then $HRCODE != 'c2880' & \ $HRCODE != 'c3072' & \ $HRCODE != 'c5760' & \ - $HRCODE != 'm1' & \ - $HRCODE != 'm3' & \ - $HRCODE != 'm9' & \ - $HRCODE != 'm36' & \ - $HRCODE != 'm25') then - echo " ${C1} Invalid choice, try again:${CR}" + $HRCODE != 'M01' & \ + $HRCODE != 'M03' & \ + $HRCODE != 'M09' & \ + $HRCODE != 'M25' & \ + $HRCODE != 'M36') then + echo " ${C1} Invalid choice. Note that entries are case-sensitive. Try again:${CR}" goto HRCODE endif if( $HRCODE != "$HRCODES" ) set HRCODES = `echo ${HRCODES} ${HRCODE}` @@ -231,46 +224,64 @@ if ( $HELPMODE != YES ) then set Resolution = `echo $<` endif - # figure out if one or more of the selected atmospheric resolutions is an EASE grid - - set isEASE = 0 - - foreach HRCODE ($HRCODES) - if( $HRCODE == 'm1' | \ - $HRCODE == 'm3' | \ - $HRCODE == 'm9' | \ - $HRCODE == 'm36' | \ - $HRCODE == 'm25') then - set isEASE = 1 - endif - end - - if ( $isEASE == 1 ) then - EASE_VERSION: - echo " What is the EASE grid version: EASEv1 or EASEv2 ? default is EASEv2" - set dummy = `echo $<` - - if ( $dummy == '' ) set dummy = EASEv2 - - if( $dummy == 'EASEv1' | \ - $dummy == 'EASEv2') then - set EASEVERSION = $dummy - echo "EASE grid Version is ${EASEVERSION} " - else - echo " " - echo " Invalid input, please use EASEv1 or EASEv2 " - echo " " - goto EASE_VERSION - endif - endif - else set HRCODE = null set HRCODES = null -endif +endif # if ( $HELPMODE != YES ) + +# -------------------------------- +# +# EASE Grid Version (EASEVERSION) +# set default EASE version +set EASEVERSION = EASEv2 + +echo " Options for EASE grid version (land-only):" +echo " ${C2}EASEv1${CR}" +echo " ${C2}EASEv2 (default)${CR}" +echo " " + +set isEASE = 0 + +if ( $HELPMODE != YES ) then + + # figure out if one or more of the selected atmospheric resolutions is an EASE grid + + foreach HRCODE ($HRCODES) + if( $HRCODE == 'M01' | \ + $HRCODE == 'M03' | \ + $HRCODE == 'M09' | \ + $HRCODE == 'M25' | \ + $HRCODE == 'M36') then + set isEASE = 1 + endif + end + + if ( $isEASE > 0 ) then + + echo "Enter one EASE grid version from the above list" + echo " OR press ENTER to select $EASEVERSION (current default):${CR}" + echo " " + + EASE_VERSION: + set dummy = `echo $<` + + if( $dummy == 'EASEv1' | \ + $dummy == 'EASEv2') then + set EASEVERSION = $dummy + else if ( $dummy == '' ) then + echo $EASEVERSION + else + echo " " + echo " ${C1} Invalid choice. Note that entry is case-sensitive. Try again:${CR}" + echo " " + goto EASE_VERSION + endif + endif + +endif ####################################################################### # @@ -279,21 +290,16 @@ endif if ($isEASE > 0) then set orslvs = O1 - echo " ${C1}---------------------------------------------------------------------- ${CR}" - echo " ${C1} Selected atmospheric resolution(s) include(s) EASE grid(s). ${CR}" - echo " ${C1} Setting ocean resolution to $orslvs \!\!\! ${CR}" - echo " ${C1} For a choice of ocean resolutions, exclude EASE grid selection(s) ${CR}" - echo " ${C1} from selected atmospheric resolution(s) and process separately. ${CR}" - echo " ${C1}-----------------------------------------------------------------------${CR}" + echo " ${C1}----------------------------------------------------------------------- ${CR}" + echo " ${C1} Selected atmospheric resolution(s) include(s) at least one EASE grid.${CR}" + echo " ${C1} Setting ${CR}ocean resolution ${C1}to $orslvs \!\!\! ${CR}" + echo " ${C1} For a choice of ocean resolutions, exclude EASE grid selection(s) ${CR}" + echo " ${C1} from selected atmospheric resolution(s) and process separately. ${CR}" + echo " ${C1}------------------------------------------------------------------------${CR}" echo " " else - if ( $HELPMODE != YES ) then - echo " " - echo "Enter 2-6 character alphanumeric code(s) for ocean horizontal resolution:" - echo "(Separate multiple entries by spaces.)" - else - echo "Options for ocean horizontal resolution:" - endif + echo "Options for ocean horizontal resolution:" + echo " " echo " ${C2}O1 -- Low-Resolution Reynolds 1 deg${CR} (Lon/Lat Data-Ocean: 360x180 )" echo " ${C2}O2 -- Med-Resolution Reynolds 1/4 deg${CR} (Lon/Lat Data-Ocean: 1440x720 )" echo " ${C2}O3 -- High-Resolution OSTIA 1/8 deg${CR} (Lon/Lat Data-Ocean: 2880x1440)" @@ -308,13 +314,16 @@ else if ( $HELPMODE == YES ) exit + echo " " + echo "Enter 2-6 character alphanumeric code(s) for ocean horizontal resolution from the above list." + echo "(Separate multiple entries by spaces.)" + ORSLV: set dummy = `echo $<` if (${%dummy} == 0) set dummy = "BLANK" - set dummy = `echo $dummy | tr "[:lower:]" "[:upper:]"` set orslvs = $dummy[1] foreach orslv ($dummy) @@ -328,7 +337,7 @@ ORSLV: $orslv != 'T2MOM6' & \ $orslv != 'T4MOM6' & \ $orslv != 'CS') then - echo " ${C1} Invalid choice, try again:${CR}" + echo " ${C1} Invalid choice. Note that entries are case-sensitive. Try again:${CR}" goto ORSLV endif if( $orslv != "$orslvs" ) set orslvs = `echo ${orslvs} ${orslv}` @@ -381,11 +390,14 @@ endif ####################################################################### -echo "" -echo "${C1} Land BCs version:${CR} ${C2}$lbcsv${CR}" -echo "${C1} Atmospheric resolution:${CR} ${C2}$HRCODES${CR}" -echo "${C1} Ocean resolution:${CR} ${C2}$orslvs${CR}" -echo "${C1} Output directory:${CR} ${C2}$EXPDIR${CR}" +echo "" +echo "${C1} Land BCs version:${CR} ${C2}$lbcsv${CR}" +echo "${C1} Atmospheric resolution:${CR} ${C2}$HRCODES${CR}" +if ( $isEASE > 0) then + echo "${C1} EASE grid version:${CR} ${C2}$EASEVERSION${CR}" +endif +echo "${C1} Ocean resolution:${CR} ${C2}$orslvs${CR}" +echo "${C1} Output directory:${CR} ${C2}$EXPDIR${CR}" ####################################################################### ####################################################################### @@ -443,7 +455,7 @@ else endif -if($HRCODE == m1 | $HRCODE == m3 | $HRCODE == m9 | $HRCODE == m36 | $HRCODE == m25) then +if($HRCODE == M01 | $HRCODE == M03 | $HRCODE == M09 | $HRCODE == M25 | $HRCODE == M36) then set GLOBAL_CATCH_DATA = ${input_dir}/GEOS5_10arcsec_mask.nc endif @@ -645,36 +657,68 @@ if( $HRCODE == c5760 ) then @ NX = 43200 @ NY = 21600 endif -if( $HRCODE == m1 ) then - set im = 34704 - set jm = 14616 - set grid = ease - set MGRID = M01 -endif -if( $HRCODE == m3 ) then - set im = 11568 - set jm = 4872 - set grid = ease - set MGRID = M03 -endif -if( $HRCODE == m9 ) then - set im = 3856 - set jm = 1624 - set grid = ease - set MGRID = M09 -endif -if( $HRCODE == m36 ) then - set im = 964 - set jm = 406 - set grid = ease - set MGRID = M36 -endif -if( $HRCODE == m25 ) then - set im = 1383 - set jm = 586 - set grid = ease - set MGRID = M25 + +if ( $isEASE > 0 ) then + + set grid = ease + + # im, jm must be consistent with values Fortran module EASE_conv + + if ( $EASEVERSION == EASEv1 ) then + + if( $HRCODE == M01 ) then + set im = 34668 + set jm = 14688 + endif + if( $HRCODE == M03 ) then + set im = 11556 + set jm = 4896 + endif + if( $HRCODE == M09 ) then + set im = 3852 + set jm = 1632 + endif + if( $HRCODE == M25 ) then + set im = 1383 + set jm = 586 + endif + if( $HRCODE == M36 ) then + set im = 963 + set jm = 408 + endif + + else if ( $EASEVERSION == EASEv2 ) then + + if( $HRCODE == M01 ) then + set im = 34704 + set jm = 14616 + endif + if( $HRCODE == M03 ) then + set im = 11568 + set jm = 4872 + endif + if( $HRCODE == M09 ) then + set im = 3856 + set jm = 1624 + endif + if( $HRCODE == M25 ) then + set im = 1388 + set jm = 584 + endif + if( $HRCODE == M36 ) then + set im = 964 + set jm = 406 + endif + + else + + echo " \!\!\!\! Invalid EASE grid version, stopping \!\!\!\! " + exit + + endif endif + + if( $MASKFILE == GEOS5_10arcsec_mask_freshwater-lakes.nc | $MASKFILE == GEOS5_10arcsec_mask.nc ) then @ NX = 43200 @ NY = 21600 @@ -1280,21 +1324,14 @@ endif # End Cube Test if( $grid == ease ) then echo $HRCODE - #WY noted: ease version becomes input - #if( $HRCODE == m25 ) then - # set EASEVERSION = EASEv1 - #else - # set EASEVERSION = EASEv2 - #endif - set RS = ${im}x${jm} set IM = `echo ${im} | awk '{printf "%4.4i", $1}'` set JM = `echo ${jm} | awk '{printf "%4.4i", $1}'` - set BCNAME = SMAP_${EASEVERSION}_${MGRID} + set BCNAME = SMAP_${EASEVERSION}_${HRCODE} set BCDIR = $EXPDIR/$OUTDIR/$BCNAME.scratch set BCJOB = $BCDIR/$BCNAME.j - set THISGRID = SMAP-${EASEVERSION}-${MGRID} + set THISGRID = SMAP-${EASEVERSION}-${HRCODE} set nfiles = `find $EXPDIR -maxdepth 5 -name ${BCNAME}".j" | wc -l` if( $nfiles >= 1 ) then @@ -1338,9 +1375,9 @@ limit stacksize unlimited #if ( $EASEVERSION == EASEv2 ) then ## This section was used to make Irrigated Tiles - ##if(${MGRID} == M09 | ${MGRID} == M36) then + ##if(${HRCODE} == M09 | ${HRCODE} == M36) then ## bin/mkLandRaster.x -x ${NX} -y ${NY} -v -t ${NT} - ## bin/mkEASETilesParam.x -ease_label ${MGRID} -pfaf_til T + ## bin/mkEASETilesParam.x -ease_label ${HRCODE} -pfaf_til T ## bin/CombineRasters.x -f 0 -t 232000000 ${THISGRID} Pfafstetter > /dev/null ## bin/CombineRasters.x -t 232000000 ${THISGRID} ${THISGRID}-Pfafstetter ## /bin/mv til/${THISGRID}_${THISGRID}-Pfafstetter.til til/${THISGRID}_${THISGRID}-Pfafstetter.ind @@ -1359,7 +1396,7 @@ chmod 755 bin/create_README.csh bin/create_README.csh /bin/mv clsm clsm.${IM}x${JM} -/bin/cp til/SMAP_${EASEVERSION}_${MGRID}_${RS}.til clsm.${IM}x${JM} +/bin/cp til/SMAP_${EASEVERSION}_${HRCODE}_${RS}.til clsm.${IM}x${JM} ##/bin/cp til//${THISGRID}_${THISGRID}-Pfafstetter.TIL clsm.${IM}x${JM} cd clsm.${IM}x${JM} @@ -1375,9 +1412,9 @@ cd clsm.${IM}x${JM} cd ../ -/bin/rm -rf SMAP_${EASEVERSION}_${MGRID} -/bin/mv clsm.${IM}x${JM} SMAP_${EASEVERSION}_${MGRID} - cd SMAP_${EASEVERSION}_${MGRID} +/bin/rm -rf SMAP_${EASEVERSION}_${HRCODE} +/bin/mv clsm.${IM}x${JM} SMAP_${EASEVERSION}_${HRCODE} + cd SMAP_${EASEVERSION}_${HRCODE} mkdir clsm /bin/mv ar.new \ bf.dat \ @@ -1407,8 +1444,8 @@ cd ../ clsm cd ../ -/bin/mv rst SMAP_${EASEVERSION}_${MGRID} -/bin/mv til SMAP_${EASEVERSION}_${MGRID} +/bin/mv rst SMAP_${EASEVERSION}_${HRCODE} +/bin/mv til SMAP_${EASEVERSION}_${HRCODE} cd ../../ /bin/mv $BCDIR/$BCNAME . @@ -1418,7 +1455,7 @@ cd ../../ /bin/rm -r $OUTDIR #mkdir -p IRRIG/$BCNAME/clsm IRRIG/$BCNAME/rst -#bin/mkIrrigTiles.x -x 43200 -y 21600 -b $BCNAME -t SMAP_${EASEVERSION}_${MGRID}_${RS}.til -r _${RS}_DE -p $IRRIGTHRES +#bin/mkIrrigTiles.x -x 43200 -y 21600 -b $BCNAME -t SMAP_${EASEVERSION}_${HRCODE}_${RS}.til -r _${RS}_DE -p $IRRIGTHRES #/bin/cp $BCNAME/${THISGRID}_${THISGRID}-Pfafstetter.TIL IRRIG/$BCNAME/. _EOF_ diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 index 943cad660..db0ae03db 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkEASETilesParam.F90 @@ -106,10 +106,6 @@ PROGRAM mkEASETilesParam ! call get_command_argument(i,PF) ! if (PF == 'T') pfaf_til = .true. - !elseif ( trim(arg) == '-v' ) then - ! i = i+1 - ! call get_command_argument(i,LBCSV) - else ! stop for any other arguments print *,trim(usage1) print *,trim(usage2) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index 992bb7310..b0185e722 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -168,6 +168,11 @@ SUBROUTINE init_bcs_config (LBCSV) use_PEATMAP = .false. jpl_height = .false. + case default + + print *,'init_bcs_config(): unknown land boundary conditions version (LBCSV)' + stop + end select END SUBROUTINE init_bcs_config From 29a5629de12fca0e2fe4d0576224edf566cb23f4 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Thu, 29 Sep 2022 20:09:05 -0400 Subject: [PATCH 44/77] added documentation to EASE_conv.F90 --- .../Utils/Raster/EASE_conv.F90 | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 index 7d02a9065..2060d77d5 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/EASE_conv.F90 @@ -152,12 +152,24 @@ module EASE_conv ! version: x = { 1, 2 } ! projection: p = { M } ! only cylindrical ("M") implemented ! resolution: yy = { 01, 03, 09, 25, 36 } ! 12.5 km not yet implemented - - subroutine ease_convert (EASELabel, lat, lon, r, s) + ! + ! Coordinate arguments for ease_convert() and ease_inverse(): + ! + ! | map coords | 0-based index | # grid cells | + ! | | (real numbers!) | | + ! ---------------------------------------------------------- + ! | latitude | s | rows | + ! | longitude | r | cols | + ! + ! Indices are 0-based and run west to east (r) and north to south (s). + ! + ! -------------------------------------------------------------------- + + subroutine ease_convert (EASELabel, lat, lon, r, s) ! note odd/reversed order of (lat,lon) and (r,s) character*(*), intent(in) :: EASELabel real, intent(in) :: lat, lon - real, intent(out) :: r, s + real, intent(out) :: r, s ! r = lon index, s = lat index character(3) :: grid @@ -189,10 +201,13 @@ end subroutine ease_convert ! ******************************************************************* - subroutine ease_inverse (EASELabel, r, s, lat, lon) + subroutine ease_inverse (EASELabel, r, s, lat, lon) ! note odd/reversed order of (r,s) and (lat,lon) + + ! Note: Get lat/lon of grid cell borders by using fractional indices. + ! E.g., s=-0.5 yields northern grid cell boundary of northernmost grid cells. character*(*), intent(in) :: EASELabel - real, intent(in) :: r, s + real, intent(in) :: r, s ! r = lon index, s = lat index real, intent(out) :: lat, lon character(3) :: grid @@ -230,8 +245,8 @@ subroutine ease_extent (EASELabel, cols, rows, cell_area, ll_lon, ll_lat, ur_lon ! get commonly used EASE grid parameters character*(*), intent(in) :: EASELabel - integer, intent(out) :: cols, rows ! number of grid cells in lon and lat direction - real, optional, intent(out) :: cell_area ! [m] + integer, intent(out) :: cols, rows ! number of grid cells in lon and lat direction, resp. + real, optional, intent(out) :: cell_area ! [m^2] real, optional, intent(out) :: ll_lon ! lon of grid cell boundary in lower left corner real, optional, intent(out) :: ll_lat ! lat of grid cell boundary in lower left corner real, optional, intent(out) :: ur_lon ! lon of grid cell boundary in upper right corner From d7fb0ed043d2660d1b46300b3c77ecdaff92db7f Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 7 Oct 2022 17:14:28 -0400 Subject: [PATCH 45/77] initial check in make_bcs.py --- .../Utils/Raster/bcs_utils.py | 301 ++++++++++++++++++ .../Utils/Raster/make_bcs.py | 76 +++++ .../Utils/Raster/make_ease_bcs.py | 157 +++++++++ 3 files changed, 534 insertions(+) create mode 100755 GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/bcs_utils.py create mode 100755 GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py create mode 100755 GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_ease_bcs.py diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/bcs_utils.py b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/bcs_utils.py new file mode 100755 index 000000000..59e8fce6a --- /dev/null +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/bcs_utils.py @@ -0,0 +1,301 @@ +#!/usr/bin/env python3 +# +# source install/bin/g5_modules +# +# Newer GEOS code should load a module with GEOSpyD Python3 if not run: +# module load python/GEOSpyD/Min4.10.3_py3.9 +# + +import os +import socket +import subprocess +import shlex +import ruamel.yaml +import shutil +import questionary +import glob +from datetime import datetime + +def get_account(): + cmd = 'id -gn' + p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) + (accounts, err) = p.communicate() + p_status = p.wait() + accounts = accounts.decode().split() + return accounts[0] + +def get_config_from_answers(answers): + + grid_type = answers['grid_type'] + lbcsv = answers['bcs_version'] + resolution = answers['resolution'] + orslvs = answers['orslvs'] + + im = {} + imo = {} + jm = {} + jmo = {} + NX = 8640 + NY = 4320 + NT = 232000000 + + hostname = socket.gethostname() + input_dir = '' + if 'discover' in hostname: + input_dir = '/discover/nobackup/projects/gmao/ssd/land/l_data/LandBCs_files_for_mkCatchParam/V001/' + else: + input_dir = '/nobackup/gmao_SIteam/ModelData/l_data/LandBCs_files_for_mkCatchParam/V001/' + + maskfile = '' + + if orslvs in['O1','T2','T3','T4','T1MOM6','T2MOM6','T4MOM6']: + maskfile = 'GEOS5_10arcsec_mask_freshwater-lakes.nc' + if lbcsv in ['F25', 'GM4', 'ICA']: + maskfile = 'global.cat_id.catch.DL' + + if orslvs in['O2','O3','CS']: + maskfile = 'GEOS5_10arcsec_mask.nc' + if lbcsv in ['F25', 'GM4', 'ICA']: + maskfile = 'global.cat_id.catch.GreatLakesCaspian_Updated.DL' + + if grid_type in ['EASEv1', 'EASEv2']: + maskfile = 'GEOS5_10arcsec_mask.nc' + + imo['O1'] = 360 + jmo['O1'] = 180 + + imo['O2'] = 1440 + jmo['O2'] = 720 + + imo['O3'] = 2880 + jmo['O3'] = 1440 + + imo['T2'] = 360 + jmo['T2'] = 200 + + imo['T3'] = 720 + jmo['T3'] = 410 + + imo['T4'] = 1440 + jmo['T4'] = 1080 + + imo['T1MOM6'] = 72 + jmo['T1MOM6'] = 36 + + imo['T2MOM6'] = 360 + jmo['T2MOM6'] = 210 + + imo['T4MOM6'] = 1440 + jmo['T4MOM6'] = 1080 + + im['b'] = 144 + jm['b'] = 91 + + im['c'] = 288 + jm['c'] = 181 + + im['d'] = 576 + jm['d'] = 361 + + im['e'] = 1152 + jm['e'] = 721 + + cubed = [12,24,48, 90, 180,360,720, 768,1000,1152, 1440,1536,2880,3072,5760] + for i in cubed: + key = 'c'+str(i) + im[key] = i + jm[key] = i*6 + + if grid_type == 'EASEv2' : + im['M01'] = 34704 + jm['M01'] = 14616 + + im['M03'] = 11568 + jm['M03'] = 4872 + + im['M09'] = 3856 + jm['M09'] = 1624 + + im['M25'] = 1388 + jm['M25'] = 584 + + im['M36'] = 964 + jm['M36'] = 406 + + if grid_type == 'EASEv1' : + im['M01'] = 34668 + jm['M01'] = 14688 + + im['M03'] = 11556 + jm['M03'] = 4896 + + im['M09'] = 3852 + jm['M09'] = 1632 + + im['M25'] = 1383 + jm['M25'] = 586 + + im['M36'] = 963 + jm['M36'] = 408 + + if resolution in ['c768','c1440'] : + NX = 17280 + NY = 8640 + if resolution == 'c2800': + NX = 21600 + NY = 10800 + if resolution in ['c1536', 'c3072','c5760'] : + NX = 43200 + NY = 21600 + + if 'GEOS5_10arcsec_mask' in maskfile: + NX = 43200 + NY = 21600 + + config = {} + config['grid_type'] = grid_type + config['lbcsv'] = lbcsv + config['resolution']= resolution + config['orslvs'] = orslvs + config ['im'] = im[resolution] + config ['jm'] = jm[resolution] + config ['imo'] = imo[orslvs] + config ['jmo'] = jmo[orslvs] + config ['NX'] = NX + config ['NY'] = NY + config ['NT'] = NT + config ['MASKFILE'] = maskfile + user = os.getlogin() + config ['expdir'] = '/discover/nobackup/'+user+'/BCS_PACKAGE/'+lbcsv+'/' + now = datetime.now() + config ['outdir'] =now.strftime("%Y%m%d%H%M%S") + config ['inputdir'] = input_dir + config ['NCPUS'] = 20 + + return config + +def ask_questions(): + + questions = [ + + { + "type": "select", + "name": "bcs_version", + "message": "Select land BCS version: \n \ + *BCs produced by this code will differ from BCs in archived directories!!! \n \ + These differences are caused by compiler changes, code improvements and bug \n \ + fixes that were implemented since the archived BCs in the above-mentioned \n \ + directories were originally created. The impact of these differences on \n \ + science is insignificant, and the parameter files produced by current \n \ + code are scientifically equivalent to the corresponding archived BCs. \n", + "choices": [ \ + "F25 : Fortuna-2_5 (archived*: n/a)", \ + "GM4 : Ganymed-4_0 (archived*: /discover/nobackup/ltakacs/bcs/Ganymed-4_0/)", \ + "ICA : Icarus (archived*: /discover/nobackup/ltakacs/bcs/Icarus/)", \ + "NL3 : Icarus-NLv3 (archived*: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/)", \ + "NL4 : NLv4 [SMAPL4] (archived*: /discover/nobackup/projects/gmao/smap/bcs_NLv4/NLv4/)", \ + "NL5 : NLv5 [SMAPL4] (archived*: /discover/nobackup/projects/gmao/smap/SMAP_L4/L4_SM/bcs/CLSM_params/Icarus-NLv5_EASE/)", \ + "DEV : Development version"], + "default": "NL3 : Icarus-NLv3 (archived*: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/)", + }, + + { + "type": "select", + "name": "grid_type", + "message": "Select grid type: \n ", + "choices": ["Lat-Lon", "Cubed-Sphere", "EASEv2", "EASEv1"], + "default": "Cubed-Sphere", + }, + + { + "type": "select", + "name": "resolution", + "message": "Select lat-lon resolution: \n ", + "choices": ["b -- 2 deg", "c -- 1 deg", "d -- 1/2 deg","e -- 1/4 deg"], + "default": "d -- 1/2 deg", + "when": lambda x: x['grid_type'] == "Lat-Lon", + }, + + { + "type": "select", + "name": "resolution", + "message": "Select cubed-sphere resolution: \n ", + "choices": [ \ + "c12 -- 8 deg", \ + "c24 -- 4 deg", \ + "c48 -- 2 deg", \ + "c90 -- 1 deg", \ + "c180 -- 1/2 deg ( 56 km)", \ + "c360 -- 1/4 deg ( 28 km)", \ + "c720 -- 1/8 deg ( 14 km)", \ + "c768 -- 1/10 deg ( 12 km)", \ + "c1000 -- 1/10 deg ( 10 km)", \ + "c1152 -- 1/10 deg ( 8 km)", \ + "c1440 -- 1/16 deg ( 7 km)", \ + "c1536 -- 1/16 deg ( 7 km)", \ + "c2880 -- 1/32 deg ( 3 km)", \ + "c3072 -- 1/32 deg ( 3 km)", \ + "c5760 -- 1/64 deg ( 1.5 km)"], + "default": "c360 -- 1/4 deg ( 28 km)", + "when": lambda x: x['grid_type'] == "Cubed-Sphere", + }, + + { + "type": "select", + "name": "resolution", + "message": "Select EASE grid resolution: \n ", + "choices": [ \ + "M01 -- 1km", \ + "M03 -- 3km", \ + "M09 -- 9km", \ + "M25 -- 25km", \ + "M36 -- 36km"], + "default": "M09 -- 9km", + "when": lambda x: x['grid_type'] == "EASEv2" or x['grid_type'] == "EASEv1", + }, + + { + "type": "select", + "name": "orslvs", + "message": "Select ocean resolution: \n ", + "choices": [ \ + "O1 -- Low-Resolution Reynolds 1 deg (Lon/Lat Data-Ocean: 360x180 )", \ + "O2 -- Med-Resolution Reynolds 1/4 deg (Lon/Lat Data-Ocean: 1440x720 )", \ + "O3 -- High-Resolution OSTIA 1/8 deg (Lon/Lat Data-Ocean: 2880x1440)", \ + "T2 -- Med-Resolution Tripolar 1 deg (MOM-Tripolar-Ocean: 360x200 )", \ + "T3 -- High-Resolution Tripolar 1/2 deg (MOM-Tripolar-Ocean: 720x410 )", \ + "T4 -- High-Resolution Tripolar 1/4 deg (MOM-Tripolar-Ocean: 1440x1080)", \ + "T1MOM6 -- Low-Resolution Tripolar 5 deg (MOM6-Tripolar-Ocean: 72x36 )", \ + "T2MOM6 -- Med-Resolution Tripolar 1 deg (MOM6-Tripolar-Ocean: 360x210 )", \ + "T4MOM6 -- High-Resolution Tripolar 1/4 deg (MOM6-Tripolar-Ocean: 1440x1080)", \ + "CS -- Cubed-Sphere Ocean (Cubed-Sphere Data-Ocean )"], + "when": lambda x: x['grid_type'] == "Lat-Lon" or x['grid_type'] == "Cubed-Sphere", + }, + + + ] + answers_ = questionary.prompt(questions) + answers = {} + for key, value in answers_.items(): + answers[key] = value.split()[0] + if 'EASE' in answers['grid_type'] : answers['orslvs'] = 'O1' + + return answers + +def print_config( config, indent = 0 ): + for k, v in config.items(): + if isinstance(v, dict): + print(" " * indent, f"{k}:") + print_config(v, indent+1) + else: + print(" " * indent, f"{k}: {v}") + +if __name__ == "__main__": + + answers = ask_questions() + for key, value in answers.items(): + print(key, value) + + config = get_config_from_answers(answers) + print('\n print config file:\n') + print_config(config) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py new file mode 100755 index 000000000..ea28515f8 --- /dev/null +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +# +# source install/bin/g5_modules +# + +import sys +import argparse +import textwrap +import ruamel.yaml +from bcs_utils import * +from make_ease_bcs import * + +# Define the argument parser +def parse_args(): + + program_description = textwrap.dedent(f''' + Usage: + + Boundary Conditions (BCs) Package: + Creates surface tile and other model parameter input files + (.til [tiles], .rst [raster], and land parameters) for + combinations of atmospheric resolution, ocean resolution, + and land BCs version. + + STEP 1: Build the model. (GCM or GEOSldas) + STEP 2: cd [install-path]/bin + STEP 3: source g5_modules (for bash or zsh use g5_modules.[z]sh) + STEP 4: ./make_bcs.py + Answer the following interactive questions: + a) Select Land BCs version. + b) Select atmospheric resolution(s). + c) Select ocean resolution(s). + (Not relevant for land-only EASE-grid BCs.) + d) Enter BCs output directory. + e) Enter sponsor code for computing account. + + To skip the generation of land parameter files (ie, mkCatchParam.x), + use: ./make_bcsi.pc -noland + This option saves time when additional bcs are created that have + the exact same land parameters as an existing set of bcs because + the only difference between the two sets of bcs is the [non-tripolar] + ocean resolution. ''') + + parser = argparse.ArgumentParser(description='make bcs',epilog=program_description,formatter_class=argparse.RawDescriptionHelpFormatter) + # define a mutually exclusive group of arguments + group = parser.add_mutually_exclusive_group() + group.add_argument('-c', '--config_file', help='YAML config file') + + # Parse using parse_known_args so we can pass the rest to the remap scripts + # If config_file is used, then extra_args will be empty + # If flattened_yaml is used, then extra_args will be populated + args, extra_args = parser.parse_known_args() + return args, extra_args + +def main(): + + question_flag = False + config = '' + + # Parse the command line arguments from parse_args() capturing the arguments and the rest + command_line_args, extra_args = parse_args() + print(f'command_line_args: {command_line_args}') + config_yaml = command_line_args.config_file + + if config_yaml: + config = yaml_to_config(config_yaml) + else: + answers = ask_questions() + config = get_config_from_answers(answers) + + make_ease_bcs(config) + + +if __name__ == '__main__' : + main() + diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_ease_bcs.py b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_ease_bcs.py new file mode 100755 index 000000000..8cb5f4701 --- /dev/null +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_ease_bcs.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python3 +# +# source install/bin/g5_modules + +import os +from bcs_utils import * + + +ease_template = """ #!/bin/csh -x + +#SBATCH --output={EXPDIR}/{OUTDIR}/logs/{BCNAME}.log +#SBATCH --error={EXPDIR}/{OUTDIR}/logs/{BCNAME}.err +#SBATCH --account={account} +#SBATCH --time=12:00:00 +#SBATCH --ntasks=28 +#SBATCH --job-name={BCNAME}.j +#SBATCH --constraint=sky + +cd {BCDIR} + +/bin/ln -s {bin_dir} +source bin/g5_modules +mkdir -p til rst data/MOM5 data/MOM6 clsm/plots +cd data +ln -s {input_dir} CATCH +cd ../ +limit stacksize unlimited + +setenv MASKFILE {MASKFILE} +setenv OMP_NUM_THREADS 1 +bin/mkEASETilesParam.x -ease_label {BCNAME} +setenv OMP_NUM_THREADS 1 +bin/mkCatchParam.x -g {BCNAME} -v {lbcsv} -x {NX} -y {NY} +setenv OMP_NUM_THREADS {NCPUS} +bin/mkCatchParam.x -g {BCNAME} -v {lbcsv} -x {NX} -y {NY} +chmod 755 bin/create_README.csh +bin/create_README.csh + +/bin/mv clsm clsm.{IM}x{JM} +/bin/cp til/SMAP_{EASEVERSION}_{HRCODE}_{RS}.til clsm.{IM}x{JM} + +cd clsm.{IM}x{JM} + /bin/mv irrig.dat irrigation_{RS}_DE.dat + /bin/mv vegdyn.data vegdyn_{RS}_DE.dat + /bin/mv nirdf.dat nirdf_{RS}_DE.dat + /bin/mv visdf.dat visdf_{RS}_DE.dat + /bin/mv lai.dat lai_clim_{RS}_DE.data + /bin/mv green.dat green_clim_{RS}_DE.data + /bin/mv lnfm.dat lnfm_clim_{RS}_DE.data + /bin/mv ndvi.dat ndvi_clim_{RS}_DE.data + + +cd ../ +/bin/rm -rf SMAP_{EASEVERSION}_{HRCODE} +/bin/mv clsm.{IM}x{JM} SMAP_{EASEVERSION}_{HRCODE} + cd SMAP_{EASEVERSION}_{HRCODE} + mkdir clsm + /bin/mv ar.new \ + bf.dat \ + ts.dat \ + catchment.def \ + cti_stats.dat \ + tau_param.dat \ + soil_param.dat \ + mosaic_veg_typs_fracs \ + soil_param.first \ + bad_sat_param.tiles \ + README \ + lai.* \ + AlbMap* \ + g5fmt \ + vegetation.hst2 \ + pfaf_fractions.dat \ + plots \ + CLM_veg_typs_fracs \ + mkCatchParam.log \ + Grid2Catch_TransferData.nc \ + CLM_NDep_SoilAlb_T2m \ + CLM4.5_abm_peatf_gdp_hdm_fc \ + catch_params.nc4 \ + catchcn_params.nc4 \ + country_and_state_code.data \ + clsm + cd ../ +/bin/mv rst SMAP_{EASEVERSION}_{HRCODE} +/bin/mv til SMAP_{EASEVERSION}_{HRCODE} + +cd ../../ +/bin/mv {BCDIR}/{BCNAME} . +/bin/mv {BCJOB} {BCNAME} +/bin/mv {EXPDIR}/{OUTDIR}/logs {BCNAME}/. +/bin/mv {BCNAME}/clsm/mkCatchParam.log {BCNAME}/logs/mkCatchParam.log +/bin/rm -r {OUTDIR} + +cd {bin_dir} + +""" + +def make_ease_bcs(config): + bin_dir = os.getcwd() + if 'install/bin' not in bin_dir: + print(" please run this program in installed bin directory") + return + + grid_type = config['grid_type'] + if 'EASEv' not in grid_type : + print('This is not a EASE grid') + return + + resolution = config['resolution'] + + EASElabel = 'SMAP_'+grid_type+'_'+ resolution + now = datetime.now() + tmp_dir =now.strftime("%Y%m%d%H%M%S") + expdir = config['expdir'] + scratch_dir = expdir+ tmp_dir+'/'+EASElabel+'.scratch/' + log_dir = expdir+'/'+tmp_dir+'/logs/' + bcjob = scratch_dir+'/'+EASElabel+'.j' + if os.path.exists(bcjob): + print('please remove the run temprory directory: ' + expdir+'/'+ tmp_dir) + return + + os.makedirs(scratch_dir) + os.makedirs(log_dir) + + account = get_account() + ims = '%04d'%config['im'] + jms = '%04d'%config['jm'] + RS = ims+'x'+jms + job_script = ease_template.format(\ + account = account, \ + EXPDIR = config['expdir'], \ + OUTDIR = tmp_dir, \ + BCNAME = EASElabel, \ + bin_dir = bin_dir, \ + input_dir = config['inputdir'], \ + BCJOB = bcjob, \ + EASEVERSION = grid_type, \ + HRCODE = resolution, \ + IM = config['im'], \ + JM = config['jm'], \ + MASKFILE = config['MASKFILE'], \ + lbcsv = config['lbcsv'], \ + NX = config['NX'], \ + NY = config['NY'], \ + RS = RS,\ + BCDIR = scratch_dir, \ + NCPUS = 20) + + print(job_script) + +if __name__ == "__main__": + + answers = ask_questions() + config = get_config_from_answers(answers) + make_ease_bcs(config) + From fa8ffdeb5ec26ded0155e6334b096ef540013f24 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Sun, 9 Oct 2022 09:14:42 -0400 Subject: [PATCH 46/77] complete make_ease_bcs.py --- .../Utils/Raster/make_ease_bcs.py | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_ease_bcs.py b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_ease_bcs.py index 8cb5f4701..524bfe7b6 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_ease_bcs.py +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_ease_bcs.py @@ -6,7 +6,7 @@ from bcs_utils import * -ease_template = """ #!/bin/csh -x +ease_template = """#!/bin/csh -x #SBATCH --output={EXPDIR}/{OUTDIR}/logs/{BCNAME}.log #SBATCH --error={EXPDIR}/{OUTDIR}/logs/{BCNAME}.err @@ -92,8 +92,6 @@ /bin/mv {BCNAME}/clsm/mkCatchParam.log {BCNAME}/logs/mkCatchParam.log /bin/rm -r {OUTDIR} -cd {bin_dir} - """ def make_ease_bcs(config): @@ -145,13 +143,36 @@ def make_ease_bcs(config): NY = config['NY'], \ RS = RS,\ BCDIR = scratch_dir, \ - NCPUS = 20) - + NCPUS = config['NCPUS']) + + + ease_job = open(bcjob,'wt') + ease_job.write(job_script) + ease_job.close() + + interactive = os.getenv('SLURM_JOB_ID', default = None) + if ( interactive ) : + print('interactive mode\n') + ntasks = os.getenv('SLURM_NTASKS', default = None) + if ( not ntasks): + nnodes = int(os.getenv('SLURM_NNODES', default = '1')) + ncpus = int(os.getenv('SLURM_CPUS_ON_NODE', default = '28')) + subprocess.call(['chmod', '755', bcjob]) + print(bcjob+ ' 1>' + log_name + ' 2>&1') + os.system(bcjob + ' 1>' + log_name+ ' 2>&1') + else: + print("sbatch " + bcjob +"\n") + subprocess.call(['sbatch', bcjob]) + + print( "cd " + bin_dir) + os.chdir(bin_dir) + print(job_script) if __name__ == "__main__": answers = ask_questions() config = get_config_from_answers(answers) + print("make_ease_bcs") make_ease_bcs(config) From 072ab2973f68ea22fb57825770a7d929c6eb3754 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Tue, 18 Oct 2022 11:26:42 -0400 Subject: [PATCH 47/77] initial check in making latlon and cube bcs. Not working yet --- .../Utils/Raster/make_cube_bcs.py | 422 ++++++++++++++++++ .../Utils/Raster/make_latlon_bcs.py | 226 ++++++++++ 2 files changed, 648 insertions(+) create mode 100755 GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_cube_bcs.py create mode 100755 GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_latlon_bcs.py diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_cube_bcs.py b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_cube_bcs.py new file mode 100755 index 000000000..52cf736d5 --- /dev/null +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_cube_bcs.py @@ -0,0 +1,422 @@ +#!/usr/bin/env python3 +# +# source install/bin/g5_modules + +import os +from bcs_utils import * + +cube_template = """ +#!/bin/csh -x + +#SBATCH --output={EXPDIR}/{OUTDIR}/logs/{BCNAME}.log +#SBATCH --error={EXPDIR}/{OUTDIR}/logs/{BCNAME}.err +#SBATCH --account={account} +#SBATCH --time=12:00:00 +#SBATCH --ntasks=28 +#SBATCH --job-name={BCNAME}.j +#SBATCH --constraint=sky + +cd {BCDIR} + +/bin/ln -s {bin_dir} +source bin/g5_modules +mkdir -p til rst data/MOM5 data/MOM6 clsm/plots +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM5/360x200 data/MOM5/360x200 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM5/720x410 data/MOM5/720x410 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM5/1440x1080 data/MOM5/1440x1080 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM6/72x36 data/MOM6/72x36 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM6/1440x1080 data/MOM6/1440x1080 + +cd data +ln -s {input_dir} CATCH + +cd ../ +if( -e CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}.stdout ) /bin/rm -f CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}.stdout +setenv MASKFILE {MASKFILE} +limit stacksize unlimited +bin/mkCubeFVRaster.x -x {NX} -y {NY} {NC} >/dev/null +bin/mkLandRaster.x -x {NX} -y {NY} -v -t {NT} + +if( {LATLON_OCEAN} == TRUE ) then + bin/mkLatLonRaster.x -x {NX} -y {NY} -b DE -p PE -t 0 {IMO} {JMO} >/dev/null + bin/CombineRasters.x -f 0 -t {NT} DE{IMO}xPE{JMO} Pfafstetter >/dev/null + bin/CombineRasters.x -t {NT} CF{NC}x6C DE{IMO}xPE{JMO}-Pfafstetter + setenv OMP_NUM_THREADS 1 + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_DE{IMO}xPE{JMO}-Pfafstetter -v {lbcsv} + setenv OMP_NUM_THREADS {NCPUS} + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_DE{IMO}xPE{JMO}-Pfafstetter -v {lbcsv} + chmod 755 bin/create_README.csh + bin/create_README.csh +endif + +if( {TRIPOL_OCEAN} == TRUE ) then + bin/mkMOMAquaRaster.x -x {NX} -y {NY} data/{MOM_VERSION}/{imo}x{jmo}/MAPL_Tripolar.nc > /dev/null + /bin/cp til/Pfafstetter.til til/Pfafstetter-ORIG.til + /bin/cp rst/Pfafstetter.rst rst/Pfafstetter-ORIG.rst + bin/FillMomGrid.x -f 0 -g Pfafstetter-M {DATENAME}{IMO}x{POLENAME}{JMO} Pfafstetter data/{MOM_VERSION}/{imo}x{jmo}/MAPL_Tripolar.nc + /bin/mv til/Pfafstetter-M.til til/Pfafstetter.til + /bin/mv rst/Pfafstetter-M.rst rst/Pfafstetter.rst + bin/CombineRasters.x -f 0 -t {NT} {DATENAME}{IMO}x{POLENAME}{JMO} Pfafstetter >/dev/null + bin/CombineRasters.x -t {NT} CF{NC}x6C {DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter + bin/mk_runofftbl.x CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter + setenv OMP_NUM_THREADS 1 + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter -v {lbcsv} + setenv OMP_NUM_THREADS {NCPUS} + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter -v {lbcsv} + chmod 755 bin/create_README.csh + bin/create_README.csh +endif +if( {CUBED_SPHERE_OCEAN} == TRUE ) then + bin/CombineRasters.x -f 0 -t {NT} CF{NC}x6C Pfafstetter >/dev/null + bin/CombineRasters.x -t {NT} CF{NC}x6C CF{NC}x6C-Pfafstetter + setenv OMP_NUM_THREADS 1 + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_CF{NC}x6C-Pfafstetter -v {lbcsv} + setenv OMP_NUM_THREADS {NCPUS} + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_CF{NC}x6C-Pfafstetter -v {lbcsv} + chmod 755 bin/create_README.csh + bin/create_README.csh +endif + +/bin/mv clsm clsm.C{NC} +/bin/cp til/CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til clsm.C{NC} +if( {TRIPOL_OCEAN} == TRUE ) /bin/cp til/CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.TRN clsm.C{NC} +/bin/rm clsm.C{NC}/CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.file + +cd clsm.C{NC} + /bin/mv irrig.dat irrigation_{RC}.dat + /bin/mv vegdyn.data vegdyn_{RC}.dat + /bin/mv nirdf.dat nirdf_{RC}.dat + /bin/mv visdf.dat visdf_{RC}.dat + /bin/mv lai.dat lai_clim_{RC}.data + /bin/mv green.dat green_clim_{RC}.data + /bin/mv lnfm.dat lnfm_clim_{RC}.data + /bin/mv ndvi.dat ndvi_clim_{RC}.data + +/bin/rm -f sedfile +if( {CUBED_SPHERE_OCEAN} == TRUE ) then +cat > sedfile << EOF +s/{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter/OC{nc}x{nc6}-CF/g +s/CF{NC}x6C/PE{nc}x{nc6}-CF/g +EOF +sed -f sedfile CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til > tile.file +/bin/mv -f tile.file CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til +/bin/rm -f sedfile +else +cat > sedfile << EOF +s/CF{NC}x6C/PE{nc}x{nc6}-CF/g +s/{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter/PE{imo}x{jmo}-{DATENAME}/g +EOF +sed -f sedfile CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til > tile.file +/bin/mv -f tile.file CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til +/bin/rm -f sedfile +endif + +cd ../ + +/bin/rm -rf CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} +/bin/mv clsm.C{NC} CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} + cd CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} + mkdir clsm + /bin/mv ar.new \ + bf.dat \ + ts.dat \ + catchment.def \ + cti_stats.dat \ + tau_param.dat \ + soil_param.dat \ + mosaic_veg_typs_fracs \ + soil_param.first \ + README \ + bad_sat_param.tiles \ + lai.* \ + AlbMap* \ + plots \ + CLM_veg_typs_fracs \ + mkCatchParam.log \ + CLM_NDep_SoilAlb_T2m \ + CLM4.5_abm_peatf_gdp_hdm_fc \ + catch_params.nc4 \ + catchcn_params.nc4 \ + country_and_state_code.data \ + clsm + cd ../ + +/bin/mv rst CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} +/bin/mv til CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} +/bin/mv {BCJOB} CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}/. +cd ../../ +/bin/mv {BCDIR}/{BCNAME} . +/bin/mv {BCJOB} {BCNAME} +/bin/mv {EXPDIR}/{OUTDIR}/logs {BCNAME}/. +/bin/mv {BCNAME}/clsm/mkCatchParam.log {BCNAME}/logs/mkCatchParam.log +/bin/rm -r {OUTDIR} +""" + +cube_template_1 = """ +#!/bin/csh -x + +#SBATCH --output={EXPDIR}/{OUTDIR}/logs/{BCNAME}.log +#SBATCH --error={EXPDIR}/{OUTDIR}/logs/{BCNAME}.err +#SBATCH --account={account} +#SBATCH --time=12:00:00 +#SBATCH --ntasks=1 +#SBATCH --job-name={BCNAME}.j +#SBATCH --constraint=sky + +cd {BCDIR} + +/bin/ln -s {bin_dir} +source bin/g5_modules +mkdir -p til rst data/MOM5 data/MOM6 clsm/plots +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM5/360x200 data/MOM5/360x200 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM5/720x410 data/MOM5/720x410 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM5/1440x1080 data/MOM5/1440x1080 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM6/72x36 data/MOM6/72x36 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM6/1440x1080 data/MOM6/1440x1080 + +cd data +ln -s {input_dir} CATCH +cd ../ + +if( -e CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}.stdout ) /bin/rm -f CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}.stdout +setenv MASKFILE {MASKFILE} +limit stacksize unlimited +bin/mkCubeFVRaster.x -x {NX} -y {NY} {NC} >/dev/null +bin/mkLandRaster.x -x {NX} -y {NY} -v -t {NT} +if( {LATLON_OCEAN} == TRUE ) then + bin/mkLatLonRaster.x -x {NX} -y {NY} -b DE -p PE -t 0 {IMO} {JMO} >/dev/null + bin/CombineRasters.x -f 0 -t {NT} DE{IMO}xPE{JMO} Pfafstetter >/dev/null + bin/CombineRasters.x -t {NT} CF{NC}x6C DE{IMO}xPE{JMO}-Pfafstetter + setenv OMP_NUM_THREADS 1 + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_DE{IMO}xPE{JMO}-Pfafstetter -v {lbcsv} +endif + +if( {TRIPOL_OCEAN} == TRUE ) then + bin/mkMOMAquaRaster.x -x {NX} -y {NY} data/{MOM_VERSION}/{imo}x{jmo}/MAPL_Tripolar.nc > /dev/null + /bin/cp til/Pfafstetter.til til/Pfafstetter-ORIG.til + /bin/cp rst/Pfafstetter.rst rst/Pfafstetter-ORIG.rst + bin/FillMomGrid.x -f 0 -g Pfafstetter-M {DATENAME}{IMO}x{POLENAME}{JMO} Pfafstetter data/{MOM_VERSION}/{imo}x{jmo}/MAPL_Tripolar.nc + /bin/mv til/Pfafstetter-M.til til/Pfafstetter.til + /bin/mv rst/Pfafstetter-M.rst rst/Pfafstetter.rst + bin/CombineRasters.x -f 0 -t {NT} {DATENAME}{IMO}x{POLENAME}{JMO} Pfafstetter >/dev/null + bin/CombineRasters.x -t {NT} CF{NC}x6C {DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter + bin/mk_runofftbl.x CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter + setenv OMP_NUM_THREADS 1 + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter -v {lbcsv} +endif + +if( {CUBED_SPHERE_OCEAN} == TRUE ) then + bin/CombineRasters.x -f 0 -t {NT} CF{NC}x6C Pfafstetter >/dev/null + bin/CombineRasters.x -t {NT} CF{NC}x6C CF{NC}x6C-Pfafstetter + setenv OMP_NUM_THREADS 1 + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_CF{NC}x6C-Pfafstetter -v {lbcsv} +endif +""" + +cube_template_2 = """ +#!/bin/csh -x + +#SBATCH --output={EXPDIR}/{OUTDIR}/logs/{BCNAME}-2.log +#SBATCH --error={EXPDIR}/{OUTDIR}/logs/{BCNAME}-2.err +#SBATCH --account={account} +#SBATCH --time=12:00:00 +#SBATCH --ntasks=28 +#SBATCH --job-name={BCNAME}-2.j +#SBATCH --constraint=sky + +cd {BCDIR} + +source bin/g5_modules + +setenv MASKFILE {MASKFILE} +limit stacksize unlimited + +if( {LATLON_OCEAN} == TRUE ) then + setenv OMP_NUM_THREADS {NCPUS} + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_DE{IMO}xPE{JMO}-Pfafstetter -v {lbcsv} + chmod 755 bin/create_README.csh + bin/create_README.csh +endif + +if( {TRIPOL_OCEAN} == TRUE ) then + setenv OMP_NUM_THREADS {NCPUS} + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter -v {lbcsv} + chmod 755 bin/create_README.csh + bin/create_README.csh +endif + +if( {CUBED_SPHERE_OCEAN} == TRUE ) then + setenv OMP_NUM_THREADS {NCPUS} + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g CF{NC}x6C_CF{NC}x6C-Pfafstetter -v {lbcsv} + chmod 755 bin/create_README.csh + bin/create_README.csh +endif +/bin/mv clsm clsm.C{NC} +/bin/cp til/CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til clsm.C{NC} +if( {TRIPOL_OCEAN} == TRUE ) /bin/cp til/CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.TRN clsm.C{NC} +/bin/rm clsm.C{NC}/CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.file + +cd clsm.C{NC} + /bin/mv irrig.dat irrigation_{RC}.dat + /bin/mv vegdyn.data vegdyn_{RC}.dat + /bin/mv nirdf.dat nirdf_{RC}.dat + /bin/mv visdf.dat visdf_{RC}.dat + /bin/mv lai.dat lai_clim_{RC}.data + /bin/mv green.dat green_clim_{RC}.data + /bin/mv lnfm.dat lnfm_clim_{RC}.data + /bin/mv ndvi.dat ndvi_clim_{RC}.data + +/bin/rm -f sedfile +if( {CUBED_SPHERE_OCEAN} == TRUE ) then +cat > sedfile << EOF +s/{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter/OC{nc}x{nc6}-CF/g +s/CF{NC}x6C/PE{nc}x{nc6}-CF/g +EOF +sed -f sedfile CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til > tile.file +/bin/mv -f tile.file CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til +/bin/rm -f sedfile +else +cat > sedfile << EOF +s/CF{NC}x6C/PE{nc}x{nc6}-CF/g +s/{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter/PE{imo}x{jmo}-{DATENAME}/g +EOF +sed -f sedfile CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til > tile.file +/bin/mv -f tile.file CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til +/bin/rm -f sedfile +endif +cd ../ + +/bin/rm -rf CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} +/bin/mv clsm.C{NC} CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} + cd CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} + mkdir clsm + /bin/mv ar.new \ + bf.dat \ + ts.dat \ + catchment.def \ + cti_stats.dat \ + tau_param.dat \ + soil_param.dat \ + mosaic_veg_typs_fracs \ + soil_param.first \ + README \ + bad_sat_param.tiles \ + lai.* \ + AlbMap* \ + plots \ + CLM_veg_typs_fracs \ + mkCatchParam.log \ + CLM_NDep_SoilAlb_T2m \ + CLM4.5_abm_peatf_gdp_hdm_fc \ + catch_params.nc4 \ + catchcn_params.nc4 \ + country_and_state_code.data \ + clsm + cd ../ +/bin/mv rst CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} +/bin/mv til CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO} +/bin/mv {BCJOB}-2 CF{NC}x6C_{DATENAME}{IMO}x{POLENAME}{JMO}/. +cd ../../ +/bin/mv {BCDIR}/{BCNAME} . +/bin/mv {BCJOB}-2 {BCNAME} +/bin/mv {EXPDIR}/{OUTDIR}/logs {BCNAME}/. +/bin/mv {BCNAME}/clsm/mkCatchParam.log {BCNAME}/logs/mkCatchParam.log +/bin/rm -r {OUTDIR} +""" + +def make_cube_bcs(config): + bin_dir = os.getcwd() + if 'install/bin' not in bin_dir: + print(" please run this program in installed bin directory") + return + + grid_type = config['grid_type'] + if 'Cubed' not in grid_type : + print('This is not a Cubed-Sphere grid') + return + + resolution = config['resolution'] + + account = get_account() + IMO = '%04d'%config['imo'] + JMO = '%04d'%config['jmo'] + NC = '%04d'%config['im'] + imo = config['imo'] + jmo = config['imo'] + nc = config['im'] + + bcname = 'CF'+NC+'x6C_'+DATENAME+imo+'x'+POLENAME+jmo + if config['CUBED_SPHERE_OCEAN'] : + bcname = 'CF'+NC'x6_CF'+NC+'6C' + DATENAME = 'CF' + POLENAME = '' + imo = NC + jmo = '6C' + + + + now = datetime.now() + tmp_dir =now.strftime("%Y%m%d%H%M%S") + expdir = config['expdir'] + scratch_dir = expdir+ tmp_dir+'/'+bcname+'.scratch/' + log_dir = expdir+'/'+tmp_dir+'/logs/' + bcjob = scratch_dir+'/'+bcname+'.j' + + if os.path.exists(bcjob): + print('please remove the run temprory directory: ' + expdir+'/'+ tmp_dir) + return + + os.makedirs(scratch_dir) + os.makedirs(log_dir) + + job_script = ease_template.format(\ + account = account, \ + EXPDIR = config['expdir'], \ + OUTDIR = tmp_dir, \ + BCNAME = bcname, \ + bin_dir = bin_dir, \ + input_dir = config['inputdir'], \ + BCJOB = bcjob, \ + EASEVERSION = grid_type, \ + HRCODE = resolution, \ + IM = config['im'], \ + JM = config['jm'], \ + MASKFILE = config['MASKFILE'], \ + lbcsv = config['lbcsv'], \ + NX = config['NX'], \ + NY = config['NY'], \ + RS = RS,\ + BCDIR = scratch_dir, \ + NCPUS = config['NCPUS']) + + + ease_job = open(bcjob,'wt') + ease_job.write(job_script) + ease_job.close() + + interactive = os.getenv('SLURM_JOB_ID', default = None) + if ( interactive ) : + print('interactive mode\n') + ntasks = os.getenv('SLURM_NTASKS', default = None) + if ( not ntasks): + nnodes = int(os.getenv('SLURM_NNODES', default = '1')) + ncpus = int(os.getenv('SLURM_CPUS_ON_NODE', default = '28')) + subprocess.call(['chmod', '755', bcjob]) + print(bcjob+ ' 1>' + log_name + ' 2>&1') + os.system(bcjob + ' 1>' + log_name+ ' 2>&1') + else: + print("sbatch " + bcjob +"\n") + subprocess.call(['sbatch', bcjob]) + + print( "cd " + bin_dir) + os.chdir(bin_dir) + + print(job_script) + +if __name__ == "__main__": + + answers = ask_questions() + config = get_config_from_answers(answers) + print("make_ease_bcs") + make_ease_bcs(config) + diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_latlon_bcs.py b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_latlon_bcs.py new file mode 100755 index 000000000..0591c1074 --- /dev/null +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_latlon_bcs.py @@ -0,0 +1,226 @@ +#!/usr/bin/env python3 +# +# source install/bin/g5_modules + +import os +from bcs_utils import * + + +ease_template = """#!/bin/csh -x + +#SBATCH --output={EXPDIR}/{OUTDIR}/logs/{BCNAME}.log +#SBATCH --error={EXPDIR}/{OUTDIR}/logs/{BCNAME}.err +#SBATCH --account={account} +#SBATCH --time=12:00:00 +#SBATCH --ntasks=28 +#SBATCH --job-name={BCNAME}.j +#SBATCH --constraint=sky + +cd {BCDIR} + +source bin/g5_modules +/bin/ln -s {bin_dir} +mkdir -p til rst data/MOM5 data/MOM6 clsm/plots +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM5/360x200 data/MOM5/360x200 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM5/720x410 data/MOM5/720x410 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM5/1440x1080 data/MOM5/1440x1080 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM6/72x36 data/MOM6/72x36 +ln -s /discover/nobackup/projects/gmao/ssd/aogcm/ocean_bcs/MOM6/1440x1080 data/MOM6/1440x1080 + +cd data +ln -s {input_dir} CATCH +cd ../ + +if( -e DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO}.stdout ) /bin/rm -f DC{IM}xPC{JM}_{DATENAME}{IMO}{POLENAME}{JMO}.stdout +setenv MASKFILE {MASKFILE} +limit stacksize unlimited +bin/mkLatLonRaster.x -x {NX} -y {NY} -t -1 {IM} {JM} >/dev/null +bin/mkLandRaster.x -x {NX} -y {NY} -v -t {NT} + +if( {LATLON_OCEAN} == TRUE ) then + bin/mkLatLonRaster.x -x {NX} -y {NY} -b DE -p PE -t 0 {IMO} {JMO} >/dev/null + bin/CombineRasters.x -f 0 -t {NT} DE{IMO}xPE{JMO} Pfafstetter >/dev/null + bin/CombineRasters.x -t {NT} DC{IM}xPC{JM} DE{IMO}xPE{JMO}-Pfafstetter + setenv OMP_NUM_THREADS 1 + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g DC{IM}xPC{JM}_DE{IMO}xPE{JMO}-Pfafstetter -v {lbcsv} + setenv OMP_NUM_THREADS {NCPUS} + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g DC{IM}xPC{JM}_DE{IMO}xPE{JMO}-Pfafstetter -v {lbcsv} + chmod 755 bin/create_README.csh + bin/create_README.csh +endif +if( {TRIPOL_OCEAN} == TRUE ) then + bin/mkMOMAquaRaster.x -x {NX} -y {NY} data/{MOM_VERSION}/{imo}x{jmo}/MAPL_Tripolar.nc > /dev/null + /bin/cp til/Pfafstetter.til til/Pfafstetter-ORIG.til + /bin/cp rst/Pfafstetter.rst rst/Pfafstetter-ORIG.rst + bin/FillMomGrid.x -f 0 -g Pfafstetter-M {DATENAME}{IMO}x{POLENAME}{JMO} Pfafstetter data/{MOM_VERSION}/{imo}x{jmo}/MAPL_Tripolar.nc + /bin/mv til/Pfafstetter-M.til til/Pfafstetter.til + /bin/mv rst/Pfafstetter-M.rst rst/Pfafstetter.rst + bin/CombineRasters.x -f 0 -t {NT} {DATENAME}{IMO}x{POLENAME}{JMO} Pfafstetter >/dev/null + bin/CombineRasters.x -t {NT} DC{IM}xPC{JM} {DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter + bin/mk_runofftbl.x DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter + setenv OMP_NUM_THREADS 1 + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g DE{IMO}xPE{JMO}_DE{IMO}xPE{JMO}-Pfafstetter -v {lbcsv} + setenv OMP_NUM_THREADS {NCPUS} + if ({SKIPLAND} != YES) bin/mkCatchParam.x -x {NX} -y {NY} -g DE{IMO}xPE{JMO}_DE{IMO}xPE{JMO}-Pfafstetter -v {lbcsv} + chmod 755 bin/create_README.csh + bin/create_README.csh +endif + +/bin/mv clsm clsm.{IM}x{JM} +/bin/cp til/DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til clsm.{IM}x{JM} +if( {TRIPOL_OCEAN} == TRUE ) /bin/cp til/DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.TRN clsm.{IM}x{JM} +/bin/rm clsm.{IM}x{JM}/DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.file + +cd clsm.{IM}x{JM} + /bin/mv irrig.dat irrigation_{RS}_DC.dat + /bin/mv vegdyn.data vegdyn_{RS}_DC.dat + /bin/mv nirdf.dat nirdf_{RS}_DC.dat + /bin/mv visdf.dat visdf_{RS}_DC.dat + /bin/mv lai.dat lai_clim_{RS}_DC.data + /bin/mv green.dat green_clim_{RS}_DC.data + /bin/mv lnfm.dat lnfm_clim_{RS}_DC.data + /bin/mv ndvi.dat ndvi_clim_{RS}_DC.data +/bin/rm -f sedfile +cat > sedfile << EOF +s/DC{IM}xPC{JM}/PC{im}x{jm}-DC/g +s/{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter/PE{imo}x{jmo}-{DATENAME}/g +EOF +sed -f sedfile DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til > tile.file +/bin/mv -f tile.file DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO}-Pfafstetter.til +/bin/rm -f sedfile + +cd ../ + +/bin/rm -rf DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO} +/bin/mv clsm.{IM}x{JM} DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO} + cd DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO} + mkdir clsm + /bin/mv ar.new \ + bf.dat \ + ts.dat \ + catchment.def \ + cti_stats.dat \ + tau_param.dat \ + soil_param.dat \ + mosaic_veg_typs_fracs \ + soil_param.first \ + README \ + bad_sat_param.tiles \ + lai.* \ + AlbMap* \ + plots \ + CLM_veg_typs_fracs \ + mkCatchParam.log \ + CLM_NDep_SoilAlb_T2m \ + CLM4.5_abm_peatf_gdp_hdm_fc \ + catch_params.nc4 \ + catchcn_params.nc4 \ + country_and_state_code.data \ + clsm + cd ../ + +/bin/mv rst DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO} +/bin/mv til DC{IM}xPC{JM}_{DATENAME}{IMO}x{POLENAME}{JMO} + +cd ../../ +/bin/mv {BCDIR}/{BCNAME} . +/bin/mv {BCJOB} {BCNAME} +/bin/mv {EXPDIR}/{OUTDIR}/logs {BCNAME}/. +/bin/mv {BCNAME}/clsm/mkCatchParam.log {BCNAME}/logs/mkCatchParam.log +/bin/rm -r {OUTDIR} + +""" + +def make_cube_bcs(config): + bin_dir = os.getcwd() + if 'install/bin' not in bin_dir: + print(" please run this program in installed bin directory") + return + + grid_type = config['grid_type'] + if 'Cubed' not in grid_type : + print('This is not a Cubed-Sphere grid') + return + + resolution = config['resolution'] + + account = get_account() + imo = '%04d'%config['imo'] + jmo = '%04d'%config['jmo'] + NC = '%04d'%config['im'] + + bcname = 'CF'+NC+'x6C_'+DATENAME+imo+'x'+POLENAME+jmo + if config['CUBED_SPHERE_OCEAN'] : + bcname = 'CF'+NC'x6_CF'+NC+'6C' + DATENAME = 'CF' + POLENAME = '' + imo = NC + jmo = '6C' + + + + now = datetime.now() + tmp_dir =now.strftime("%Y%m%d%H%M%S") + expdir = config['expdir'] + scratch_dir = expdir+ tmp_dir+'/'+bcname+'.scratch/' + log_dir = expdir+'/'+tmp_dir+'/logs/' + bcjob = scratch_dir+'/'+bcname+'.j' + + if os.path.exists(bcjob): + print('please remove the run temprory directory: ' + expdir+'/'+ tmp_dir) + return + + os.makedirs(scratch_dir) + os.makedirs(log_dir) + + job_script = ease_template.format(\ + account = account, \ + EXPDIR = config['expdir'], \ + OUTDIR = tmp_dir, \ + BCNAME = bcname, \ + bin_dir = bin_dir, \ + input_dir = config['inputdir'], \ + BCJOB = bcjob, \ + EASEVERSION = grid_type, \ + HRCODE = resolution, \ + IM = config['im'], \ + JM = config['jm'], \ + MASKFILE = config['MASKFILE'], \ + lbcsv = config['lbcsv'], \ + NX = config['NX'], \ + NY = config['NY'], \ + RS = RS,\ + BCDIR = scratch_dir, \ + NCPUS = config['NCPUS']) + + + ease_job = open(bcjob,'wt') + ease_job.write(job_script) + ease_job.close() + + interactive = os.getenv('SLURM_JOB_ID', default = None) + if ( interactive ) : + print('interactive mode\n') + ntasks = os.getenv('SLURM_NTASKS', default = None) + if ( not ntasks): + nnodes = int(os.getenv('SLURM_NNODES', default = '1')) + ncpus = int(os.getenv('SLURM_CPUS_ON_NODE', default = '28')) + subprocess.call(['chmod', '755', bcjob]) + print(bcjob+ ' 1>' + log_name + ' 2>&1') + os.system(bcjob + ' 1>' + log_name+ ' 2>&1') + else: + print("sbatch " + bcjob +"\n") + subprocess.call(['sbatch', bcjob]) + + print( "cd " + bin_dir) + os.chdir(bin_dir) + + print(job_script) + +if __name__ == "__main__": + + answers = ask_questions() + config = get_config_from_answers(answers) + print("make_ease_bcs") + make_ease_bcs(config) + From ec240f87cd9e7d75e3d9d2070c1533776a20876d Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Wed, 26 Oct 2022 20:51:37 -0400 Subject: [PATCH 48/77] add no data values; update comments --- .../GEOS_CatchCNGridComp.F90 | 2 +- .../GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 2 +- .../Shared/GEOS_SurfaceGridComp.rc | 2 +- .../Utils/Raster/mod_process_hres_data.F90 | 46 +++++++++---------- .../Utils/Raster/rmTinyCatchParaMod.F90 | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 index f30b0328c..4bc2943fc 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 @@ -86,7 +86,7 @@ subroutine SetServices ( GC, RC ) ! SNOW ALBEDO -- so far, only parameterization based on look-up table is implemented for CatchCN ! 0 : parameterization based on look-up table - ! 1 : MODIS-derived snow albedo (where available, elsewhere fall back to option 0) + ! 1 : MODIS-derived snow albedo (where available, elsewhere no data values filled with global land average Snow_Albedo=0.56) call ESMF_ConfigGetAttribute (SCF, label='SNOW_ALBEDO_INFO:', value=SNOW_ALBEDO_INFO, DEFAULT=0, RC=STATUS) ; VERIFY_(STATUS) _ASSERT( SNOW_ALBEDO_INFO==0, "SNOW_ALBEDO_INFO must be 0 for CatchCN") diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index bf6c47ead..c4b6f33c9 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -230,7 +230,7 @@ subroutine SetServices ( GC, RC ) ! SNOW ALBEDO ! 0 : parameterization based on look-up table - ! 1 : MODIS-derived snow albedo (where available, elsewhere fall back to option 0) + ! 1 : MODIS-derived snow albedo (where available, elsewhere no data values filled with global land average Snow_Albedo=0.56) call MAPL_GetResource (SCF, SNOW_ALBEDO_INFO, label='SNOW_ALBEDO_INFO:', DEFAULT=0, __RC__ ) ! GOSWIM SNOW_ALBEDO diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc index 3491c4f5c..282985451 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc @@ -118,7 +118,7 @@ # # 0 : Snow albedo parameterization based on look-up table (default) # 1 : Snow albedo derived from MODIS Collection MOD10A1.061 (Feb/2000 - Mar/2022) [NOT YET AVAILABLE FOR CatchCN] -# where available, elsewhere fall back to option 0 +# where available, elsewhere no data values filled with global land average Snow_Albedo=0.56 # # GEOSagcm=>SNOW_ALBEDO_INFO: 0 # GEOSldas=>SNOW_ALBEDO_INFO: 0 diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index fda5b3424..ebab7f8cc 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -3010,15 +3010,13 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) real,allocatable,dimension(:) :: min_lon,max_lon,min_lat,max_lat,snw_alb integer(kind=4),parameter :: xdim = 1200, ydim = 1200 real,parameter :: alb_res=10.0/1200.0 - real,dimension(xdim) :: lon_alb - real,dimension(ydim) :: lat_alb real,dimension(xdim,ydim) :: stch_snw_alb_tmp real,dimension(36,18,xdim,ydim) :: stch_snw_alb real :: minlon,maxlon,minlat,maxlat,pad_lon,pad_lat real :: sno_alb_cnt,sno_alb_sum,sno_alb_cnt2,sno_alb_sum2 integer :: vvtil_min,hhtil_min,vvtil_max,hhtil_max,hhtil,vvtil integer :: tindex1,pfaf1 - integer(kind=4) :: dummy,varid1,varid2,varid3 + integer(kind=4) :: dummy,varid1 integer(kind=4) :: imin,imax,jmin,jmax integer(kind=4) :: imin2,imax2,jmin2,jmax2,count_init_invalid logical :: file_exists @@ -3073,18 +3071,20 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) write(vv,'(i2.2)') vvtil write(hh,'(i2.2)') hhtil - fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v1/snow_alb_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' + ! MODIS-based climatology albedo raster files filled for NoData values using global land + ! average Snow Albedo (0.56). Note: the average excludes Antarctica and Greenland ice + ! sheets and is weighted by the grid-cell area. + fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v2/snow_alb_FillVal_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' + + ! MODIS-based climatology albedo raster files (NoData set to 1e+15) + !fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v1/snow_alb_noFill_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' ! Open the file. (NF90_NOWRITE ensures read-only access to the file) status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) ! Based on vars name, get the varids. status=NF_INQ_VARID(ncid,'Snow_Albedo',VarID1) ; VERIFY_(STATUS) - status=NF_INQ_VARID(ncid,'lon' ,VarID2) ; VERIFY_(STATUS) - status=NF_INQ_VARID(ncid,'lat' ,VarID3) ; VERIFY_(STATUS) ! Read the data. status=NF_GET_VARA_REAL(ncid,VarID1,(/1,1/),(/xdim,ydim/),stch_snw_alb_tmp) ; VERIFY_(STATUS) - status=NF_GET_VARA_REAL(ncid,VarID2,(/1/) ,(/xdim/) ,lon_alb) ; VERIFY_(STATUS) - status=NF_GET_VARA_REAL(ncid,VarID3,(/1/) ,(/ydim/) ,lat_alb) ; VERIFY_(STATUS) ! Close the file, freeing all resources. status=NF_CLOSE(ncid); VERIFY_(STATUS) @@ -3096,7 +3096,7 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) ! loop over tiles print*, 'Starting tile loop for snow albedo. ' - count_init_invalid=0 ! counter for non-valid snow albedo avalues (informational use only; not needed for) + count_init_invalid=0 ! counter for non-valid snow albedo values (informational use only) do n = 1, maxcat ! loop over tiles @@ -3147,14 +3147,14 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) jmax=min(jmax,ydim) ! Generate sums and counts using current tile corresponding indices - sno_alb_sum= sno_alb_sum + & - sum(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax), & - stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & - stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax).le.1.0) + sno_alb_sum= sno_alb_sum + & + sum(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax), & + stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & + stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).le.1.0) - sno_alb_cnt= sno_alb_cnt + & - count(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & - stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin:imax,jmin:jmax).le.1.0) + sno_alb_cnt= sno_alb_cnt + & + count(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & + stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).le.1.0) end do ! vvtil end do ! hhtil @@ -3187,14 +3187,14 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) jmin2=max(jmin2,1) jmax2=min(jmax2,ydim) - sno_alb_sum2= sno_alb_sum2 + & - sum(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2), & - stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & - stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2).le.1.0) + sno_alb_sum2= sno_alb_sum2 + & + sum(stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2), & + stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & + stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).le.1.0) - sno_alb_cnt2= sno_alb_cnt2 + & - count(stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & - stch_snw_alb(hhtil:hhtil,vvtil:vvtil,imin2:imax2,jmin2:jmax2).le.1.0) + sno_alb_cnt2= sno_alb_cnt2 + & + count(stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & + stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).le.1.0) end do ! vvtil end do ! hhtil diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index 992bb7310..ac191c7cb 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -52,7 +52,7 @@ module rmTinyCatchParaMod logical, public, save :: use_PEATMAP = .false. logical, public, save :: jpl_height = .false. character*8, public, save :: LAIBCS = 'UNDEF' - character*4, public, save :: SOILBCS = 'UNDEF' + character*6, public, save :: SOILBCS = 'UNDEF' character*6, public, save :: MODALB = 'UNDEF' character*8, public, save :: SNOWALB = 'UNDEF' REAL, public, save :: GNU = MAPL_UNDEF From 49e1f246e7860abcff58eb273963afcce1e3c860 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Sun, 30 Oct 2022 19:25:22 -0400 Subject: [PATCH 49/77] adding case for Scott's testing --- .../GEOSsurface_GridComp/Utils/Raster/make_bcs | 4 +++- .../Utils/Raster/mkCatchParam.F90 | 18 +++++++++--------- .../Utils/Raster/rmTinyCatchParaMod.F90 | 9 +++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs index 2253db27f..af40fb04b 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs @@ -115,6 +115,7 @@ echo " ${C2} = NL3 + JPL veg height + PEATMAP${CR}" echo " ${C2}v06 = NL3 + JPL veg height + PEATMAP + MODIS snow alb${CR}" echo " ${C2}v07 = NL3 + PEATMAP${CR}" echo " ${C2}v08 = NL3 + MODIS snow alb${CR}" +echo " ${C2}v09 = NL3 + PEATMAP + MODIS snow alb${CR}" echo " " if ( $HELPMODE != YES ) then echo " ${C1} *BCs produced by this code will differ from BCs in archived directories\!\!\! ${CR}" @@ -142,7 +143,8 @@ if ( $HELPMODE != YES ) then $dummy == 'NL5' | \ $dummy == 'v06' | \ $dummy == 'v07' | \ - $dummy == 'v08') then + $dummy == 'v08' | \ + $dummy == 'v09') then set lbcsv = $dummy else if ( $dummy == '' ) then echo $lbcsv diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index b07b9ba3b..b88cd2fa2 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -9,7 +9,7 @@ PROGRAM mkCatchParam ! -y: Size of latitude dimension of input raster. DEFAULT: 4320 ! -b: position of the dateline in the first box. DEFAULT: DC ! -g: Gridname (name of the .til or .rst file without file extension) -! -v: LBCSV : Land bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) +! -v: LBCSV : Land bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08, v09) ! -e: EASE : This is optional if catchment.def file is available already or ! the til file format is pre-Fortuna-2. ! @@ -103,14 +103,14 @@ PROGRAM mkCatchParam ! call execute_command_line('cd data/ ; ln -s /discover/nobackup/projects/gmao/ssd/land/l_data/LandBCs_files_for_mkCatchParam/V001/ CATCH') ! call execute_command_line('cd ..') - USAGE(1) ="Usage: mkCatchParam -x nx -y ny -g Gridname -b DL -v LBCSV -e EASE " - USAGE(2) =" -x: Size of longitude dimension of input raster. DEFAULT: 8640 " - USAGE(3) =" -y: Size of latitude dimension of input raster. DEFAULT: 4320 " - USAGE(4) =" -g: Gridname (name of the .til or .rst file without file extension) " - USAGE(5) =" -b: Position of the dateline in the first grid box (DC or DE). DEFAULT: DC " - USAGE(6) =" -e: EASE : This is optional if catchment.def file is available already or " - USAGE(7) =" the til file format is pre-Fortuna-2. " - USAGE(8) =" -v LBCSV : Land bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08) " + USAGE(1) ="Usage: mkCatchParam -x nx -y ny -g Gridname -b DL -v LBCSV -e EASE " + USAGE(2) =" -x: Size of longitude dimension of input raster. DEFAULT: 8640 " + USAGE(3) =" -y: Size of latitude dimension of input raster. DEFAULT: 4320 " + USAGE(4) =" -g: Gridname (name of the .til or .rst file without file extension) " + USAGE(5) =" -b: Position of the dateline in the first grid box (DC or DE). DEFAULT: DC " + USAGE(6) =" -e: EASE : This is optional if catchment.def file is available already or " + USAGE(7) =" the til file format is pre-Fortuna-2. " + USAGE(8) =" -v LBCSV : Land bcs version (F25, GM4, ICA, NL3, NL4, NL5, v06, v07, v08, v09) " ! Process Arguments !------------------ diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 index ac191c7cb..f7d47a432 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rmTinyCatchParaMod.F90 @@ -168,6 +168,15 @@ SUBROUTINE init_bcs_config (LBCSV) use_PEATMAP = .false. jpl_height = .false. + case ("v09") + LAIBCS = 'MODGEO' + SOILBCS = 'HWSD' + MODALB = 'MODIS2' + SNOWALB = 'MODC061' + GNU = 1.0 + use_PEATMAP = .true. + jpl_height = .false. + end select END SUBROUTINE init_bcs_config From 7d22313d4cdd6b30bb8114a894d62e51c14fe280 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Tue, 1 Nov 2022 07:54:45 -0400 Subject: [PATCH 50/77] fix for CF high res bcs runs --- .../Utils/Raster/mod_process_hres_data.F90 | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index ebab7f8cc..555120adb 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -3100,6 +3100,29 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) do n = 1, maxcat ! loop over tiles + ! note: if a tile is within 30 arcsec of the date line, snow albedo value + ! will remain missing (no values between the edge of the map and tile). + ! There are very few tiles that fall into this gap. To save the computational + ! time required for looping over h01 and h36 files, those tiles are 'moved' + ! ~30 arc sec away from the date line, which will result in the assignment of + ! "neighboring" snow albedo value + if (min_lon(n) .lt. -179.99 .or. max_lon(n) .lt. -179.99) then + min_lon(n)=min_lon(n)+0.01 + max_lon(n)=max_lon(n)+0.01 + endif + if (min_lon(n) .gt. 179.99 .or. max_lon(n) .gt. 179.99) then + min_lon(n)=min_lon(n)-0.01 + max_lon(n)=max_lon(n)-0.01 + endif + if (min_lat(n) .lt. -89.99 .or. max_lat(n) .lt. -89.99) then + min_lat(n)=min_lat(n)+0.01 + max_lat(n)=max_lat(n)+0.01 + endif + if (min_lat(n) .gt. 89.99 .or. max_lat(n) .gt. 89.99) then + min_lat(n)=min_lat(n)-0.01 + max_lat(n)=max_lat(n)-0.01 + endif + ! Set sums and counts to zero sno_alb_sum =0. sno_alb_cnt =0. From 4086fd3a92f51d90c8819e143c524fe467fb12d4 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Tue, 8 Nov 2022 08:40:23 -0500 Subject: [PATCH 51/77] fix indexing --- .../Utils/Raster/mod_process_hres_data.F90 | 52 ++++++------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index 555120adb..ff39c6c7b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -3100,29 +3100,6 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) do n = 1, maxcat ! loop over tiles - ! note: if a tile is within 30 arcsec of the date line, snow albedo value - ! will remain missing (no values between the edge of the map and tile). - ! There are very few tiles that fall into this gap. To save the computational - ! time required for looping over h01 and h36 files, those tiles are 'moved' - ! ~30 arc sec away from the date line, which will result in the assignment of - ! "neighboring" snow albedo value - if (min_lon(n) .lt. -179.99 .or. max_lon(n) .lt. -179.99) then - min_lon(n)=min_lon(n)+0.01 - max_lon(n)=max_lon(n)+0.01 - endif - if (min_lon(n) .gt. 179.99 .or. max_lon(n) .gt. 179.99) then - min_lon(n)=min_lon(n)-0.01 - max_lon(n)=max_lon(n)-0.01 - endif - if (min_lat(n) .lt. -89.99 .or. max_lat(n) .lt. -89.99) then - min_lat(n)=min_lat(n)+0.01 - max_lat(n)=max_lat(n)+0.01 - endif - if (min_lat(n) .gt. 89.99 .or. max_lat(n) .gt. 89.99) then - min_lat(n)=min_lat(n)-0.01 - max_lat(n)=max_lat(n)-0.01 - endif - ! Set sums and counts to zero sno_alb_sum =0. sno_alb_cnt =0. @@ -3131,10 +3108,15 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) ! Use tile's min/max lat/lon info to identify the 10x10deg input file(s) ! and read in snow albedo value(s). The "ceiling" and "floor" implements the "halo". - vvtil_min= floor((min_lat(n)+ 90.0)/10.) - hhtil_min= floor((min_lon(n)+180.0)/10.) - vvtil_max=ceiling((max_lat(n)+ 90.0)/10.) - hhtil_max=ceiling((max_lon(n)+180.0)/10.) + vvtil_min= floor((min_lat(n)+ 90.0)/10.)+1 + hhtil_min= floor((min_lon(n)+180.0)/10.)+1 + + ! if tile crosses the edge of the snow albedo 10x10deg box, expand the + ! search area into the neighbouring 10x10deg box + hhtil_max=hhtil_min + vvtil_max=vvtil_min + if (floor(min_lon(n)/10) .ne. floor(max_lon(n)/10)) hhtil_max=hhtil_min+1 + if (floor(min_lat(n)/10) .ne. floor(max_lat(n)/10)) vvtil_max=vvtil_min+1 ! Safety checks: ! 1. Make sure vv's and hh's are within the range. If min>max, swap them. @@ -3159,10 +3141,10 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction ! Find indices ranges corresponding to the current tile area. - imin=floor((min_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) - imax=floor((max_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) - jmin=floor((min_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) - jmax=floor((max_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) + imin=floor((min_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 + imax=floor((max_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 + jmin=floor((min_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 + jmax=floor((max_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 ! Keep within the range. imin=max(imin,1) imax=min(imax,xdim) @@ -3201,10 +3183,10 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction ! Repeat the steps for extracting snow albedo value - imin2=floor((min_lon(n)-pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) - imax2=floor((max_lon(n)+pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) - jmin2=floor((min_lat(n)-pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) - jmax2=floor((max_lat(n)+pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) + imin2=floor((min_lon(n)-pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0))+1 + imax2=floor((max_lon(n)+pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0))+1 + jmin2=floor((min_lat(n)-pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0))+1 + jmax2=floor((max_lat(n)+pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0))+1 imin2=max(imin2,1) imax2=min(imax2,xdim) jmin2=max(jmin2,1) From 439f46f3274ba5e67ccbb58be21287a174e3b246 Mon Sep 17 00:00:00 2001 From: Atanas Trayanov Date: Tue, 8 Nov 2022 17:42:01 -0500 Subject: [PATCH 52/77] Fixes #210. Added adjustable tolerance to the rasterization routine. Added some heuristic logic in mkMOMAquaRaster.F90 to define a different tolerance (default is 1.0e-12, and under some conditions we change it to 1.0e-5). This fixes the failures with 5 degrees MOM6 rasters. Aslo updated the code and the build for MITgcm rasters --- .../Utils/Raster/CMakeLists.txt | 2 + .../Utils/Raster/mkMITAquaRaster.F90 | 382 ++++++++++++++---- .../Utils/Raster/mkMOMAquaRaster.F90 | 7 +- .../Utils/Raster/rasterize.H | 16 +- 4 files changed, 315 insertions(+), 92 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt index b4b947833..5fa2e6df1 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/CMakeLists.txt @@ -17,6 +17,8 @@ if(NOT FORTRAN_COMPILER_SUPPORTS_FINDLOC) list(APPEND srcs findloc.F90) endif () +set_source_files_properties(mkMITAquaRaster.F90 PROPERTIES COMPILE_FLAGS "${BYTERECLEN}") + esma_add_library(${this} SRCS ${srcs} DEPENDENCIES MAPL GEOS_SurfaceShared GEOS_LandShared esmf NetCDF::NetCDF_Fortran OpenMP::OpenMP_Fortran OpenMP::OpenMP_C) if(NOT FORTRAN_COMPILER_SUPPORTS_FINDLOC) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 index 5dd4732e8..47b7e25b2 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 @@ -1,5 +1,6 @@ #include "Raster.h" +!#define VERIFY_(A) if (A/=0) stop 'verify error' program MAIN @@ -7,44 +8,106 @@ program MAIN implicit none - integer, parameter :: NFACES = 6 integer, parameter :: IUNIT = 11, OUNIT = 12 + integer :: iargc + integer, parameter :: RKIND = 8 - integer, parameter :: LL = 1, LR = 2, UR = 3, UL = 4 + INTEGER :: NC + INTEGER :: NX, NY - integer :: command_argument_count - integer :: Nc = 8640, NR = 4320 + integer :: STATARRAY(12) + integer(kind=8) :: filesize + integer(kind=8) :: Length + integer :: K + integer :: i, j + integer :: KF, L, NF + integer :: KP + integer :: IBEG, IEND + integer :: I1,IN + integer :: J1,JN + integer :: N + integer :: nxt + REAL(kind=RKIND), POINTER :: XG(:,:), YG(:,:) + REAL(kind=RKIND), POINTER :: rA(:,:) + real(kind=RKIND), pointer :: XT(:,: ), YT(:,: ) + real(kind=RKIND), allocatable :: XV(:,:,:), YV(:,:,:) + + character(len=128) :: GridDir + character(len=128) :: & + Usage = "mkMITAquaRaster -x rx -y ry -z -v GridDir" + character*(128) :: RasterFile, arg + CHARACTER (LEN=128) :: FACEFILE + CHARACTER (LEN=2) :: opt + logical :: haveit + logical :: isLLC + logical :: DoZip =.false. + logical :: Verb =.false. + integer :: pNX, pNY + integer :: nFaces + integer :: nTotal + integer :: nCPU + integer :: status + integer, ALLOCATABLE :: scaleX(:), scaleY(:) + + integer, parameter :: LL = 1, LR = 2, UR = 3, UL = 4 + integer :: Ncol = 8640, NRow = 4320 type Ptr2 real(kind=RKIND), pointer :: V(:,:) end type Ptr2 - type(Ptr2) :: X(4), Y(4) - real(kind=RKIND), pointer :: XG(:,: ), YG(:,: ) - real(kind=RKIND), allocatable :: XV(:,:,:), YV(:,:,:) - - integer :: STATUS - integer :: STATARRAY(12) - integer :: IBEG, IEND - integer :: K, N, i, j, NX, NY, Length, NXT - integer, allocatable :: RASTER(:,:) - - character*(128) :: RasterFile, arg - character*80 :: FACEFILE(NFACES) = (/ & - '/tile001.mitgrid', '/tile002.mitgrid', '/tile003.mitgrid', & - '/tile004.mitgrid', '/tile005.mitgrid', '/tile006.mitgrid' /) - - logical :: DoZip =.false. - logical :: Verb =.false. - character*(128) :: GridDir - character*(2) :: OPT - character*(128) :: & - Usage = "mkMITAquaRaster -x rx -y ry -z -v GridDir" + type(Ptr2) :: X(4), Y(4) + + + ! specific values for LLC90 +! integer, parameter :: BLNKSZ = 4 +! integer, parameter :: sNX = 45 +! integer, parameter :: sNY = 45 +! integer, parameter :: BLNKSZ = 21 +! integer, parameter :: sNX = 30 +! integer, parameter :: sNY = 30 +! integer, parameter :: BLNKSZ = 42 +! integer, parameter :: sNX = 15 +! integer, parameter :: sNY = 30 +! integer, parameter :: BLNKSZ = 108 +! integer, parameter :: sNX = 15 +! integer, parameter :: sNY = 15 + +! integer, dimension(*), parameter :: blankList = & ! intel 2008 feature! +! integer, dimension(BLNKSZ), parameter :: blankList = & +! sizes for 45x45 +! [2,13,14,23] +! sizes for 30x30 +! [1,2,3,5,6,28,29,30,31,32,33,49,50,52,53,72,81,90,99,108,117] +!#15x30 nprocs = 192 +!# blankList(1:42)= +! [1,2,3,4,5,6,9,10,11,12,55,56,57,58,59,60,61,62,63,64,65,66, & +! 97,98,99,100,103,104,105,106,143,144,& +! 161,162,179,180,197,198,215,216,233,234] +!#15x15 nprocs = 360 +!# blankList(1:108) +! [1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,21,22,23,24,& +! 65,71,75,76,90,95,96,101,102,109,110,111,112,113,114,115,116,117,118,119,& +! 120,121,122,123,124,125,126,127,128,129,130,131,132,& +! 188,189,190,193,194,195,196,199,& +! 200,201,202,203,205,206,207,208,209,211,212,213,214,215,216,242,247,253,& +! 267,268,269,270,287,288,305,306,323,324,341,342,359,360,362,376,377,378,& +! 380,381,382,395,396,400,412,413,414,430] + + integer :: sNX + integer :: sNY + integer, parameter :: MAXBLNKSZ = 25000 + integer :: BLNKSZ + integer, dimension(MAXBLNKSZ) :: blankList + + real(kind=RKIND) :: areamin, xc, yc + + NAMELIST /W2_EXCH2_PARM01/ sNx, SNy, blankList ! Get source grid directory and destination raster file names !------------------------------------------------------------ - i = command_argument_count() + i = iargc() if(I < 2 .or. i > 7) then print *, "Wrong Number of arguments: ", i @@ -53,13 +116,13 @@ program MAIN end if nxt = 1 - call get_command_argument(nxt,arg) + call getarg(nxt,arg) do while(arg(1:1)=='-') opt=arg(2:2) if(len(trim(arg))==2) then if(scan(opt,'zv')==0) then nxt = nxt + 1 - call get_command_argument(nxt,arg) + call getarg(nxt,arg) endif else arg = arg(3:) @@ -67,9 +130,9 @@ program MAIN select case (opt) case ('x') - read(arg,'(i6)') nc + read(arg,'(i6)') ncol case ('y') - read(arg,'(i6)') nr + read(arg,'(i6)') nrow case ('z') DoZip = .true. case ('v') @@ -79,108 +142,253 @@ program MAIN call exit(1) end select nxt = nxt + 1 - call get_command_argument(nxt,arg) + call getarg(nxt,arg) end do GridDir = arg -! Find size of a grid face -!------------------------- + blanklist = 0 + OPEN(UNIT=iUnit, name='data.exch2', form='formatted', status='old') + READ(UNIT=iUnit,NML=W2_EXCH2_PARM01) + CLOSE(iUnit) + BLNKSZ = count(blanklist /= 0) - open (20,file=trim(GridDir)//'/tile001.mitgrid', status='old') - call fstat(20,statarray) - close (20) + ! Open Facet 3 first. It is always a square (CS or LLC) + open (IUNIT,file=trim(GridDir)//'/tile003.mitgrid', status='old') + call fstat(IUNIT,statarray) + close (IUNIT) + filesize = statarray(8) - LENGTH = statarray(8)/rkind + !ALT: Kludge for LLC4320 + if (filesize <= 0) filesize = 2389893248 +! print *,'file size=',filesize - do k=16,20 - if(mod(length,k)==0) exit - enddo + LENGTH = filesize/rkind - if(k==21) then - print *, 'Bad GMIT grid file', trim(GridDir)//'/tile001.mitgrid' - call exit(1) - end if + do k=16,20 + if(mod(length,k)==0) exit + enddo - nx = nint(sqrt(length/real(k,kind=rkind))) - ny = nx + if(k==21) then + print *, 'Bad GMIT grid file', trim(GridDir)//'/tile003.mitgrid' + call exit(1) + end if - LENGTH = nx*ny*rkind + nc = nint(sqrt(length/real(k,kind=rkind))) + ! nc = 4321 + + nx = nc-1 + ny = nc-1 + + LENGTH = nx*ny*rkind + + ! Open Facet 1 to check sizes CS or LLC) + open (IUNIT,file=trim(GridDir)//'/tile001.mitgrid', status='old') + call fstat(IUNIT,statarray) + close (IUNIT) + + filesize = statarray(8) + + !ALT: Kludge for LLC4320 + if (filesize <= 0) filesize = 7168573568 +! print *,'file size=',filesize + + LENGTH = filesize/(rkind * k) + + if (LENGTH == NC*NC) then ! cubed-sphere + isLLC = .false. + elseif (LENGTH == (3*(NC-1)+1)*NC) then ! LLC + isLLC = .true. + else + print *, 'ERROR: Unknown grid type' + call exit(1) + end if + + if(Verb) then + print * + if (isLLC) then + print *, 'Processing LLC ', nx + else + print *, 'Processing CS ', nx + end if + end if - if(Verb) then - print * - print *, 'Processing cube ', nx-1, ' points on a side.' - end if - write(RasterFile,'(A2,I4.4,A3,I4.4)') "CM",nx-1,"xCM",6*(nx-1) - if(DoZip) RasterFile = trim(RasterFile)//'.gz' +! Find size of a grid face +!------------------------- + + if (isLLC) then + nFaces = 5 + else + ! CS + nFaces = 6 + end if + allocate(scaleX(nFaces), scaleY(nFaces), stat=status) + scaleX = 1 + scaleY = 1 + if (isLLC) then + scaleX = [1,1,1,3,3] + scaleY = [3,3,1,1,1] + end if + + + pNX = NX/sNX + pNY = NY/sNY + + nTotal = dot_product(scaleX*pNX,scaleY*pNY) + nCPU = ntotal-BLNKSZ + + write(RasterFile,'(A2,I9.9,A3,I9.9)') "LLC",nCPU*sNX,"xLLC",sNY + if(DoZip) RasterFile = trim(RasterFile)//'.gz' ! Initialize the raster array !----------------------------- - allocate(RASTER(nc,nr) ,stat=STATUS); VERIFY_(STATUS) - RASTER = RASTERUNDEF +! allocate(RASTER(nc,nr) ,stat=STATUS); VERIFY_(STATUS) +! RASTER = RASTERUNDEF ! Allocate space for symmetric version of coordinates !---------------------------------------------------- - allocate(XG(NX ,NY ),stat=STATUS); VERIFY_(STATUS) - allocate(YG(NX ,NY ),stat=STATUS); VERIFY_(STATUS) + allocate(XT(sNX+1, sNY+1 ),stat=STATUS); VERIFY_(STATUS) + allocate(YT(sNX+1, sNY+1 ),stat=STATUS); VERIFY_(STATUS) ! Set pointers to coordinates of four corners (asymmetric) !--------------------------------------------------------- - X(LL)%V => XG(1:NX-1,1:NY-1) - X(LR)%V => XG(2:NX ,1:NY-1) - X(UR)%V => XG(2:NX ,2:NY ) - X(UL)%V => XG(1:NX-1,2:NY ) + X(LL)%V => XT(1:sNX ,1:sNY ) + X(LR)%V => XT(2:sNX+1,1:sNY ) + X(UR)%V => XT(2:sNX+1,2:sNY+1) + X(UL)%V => XT(1:sNX ,2:sNY+1) - Y(LL)%V => YG(1:NX-1,1:NY-1) - Y(LR)%V => YG(2:NX ,1:NY-1) - Y(UR)%V => YG(2:NX ,2:NY ) - Y(UL)%V => YG(1:NX-1,2:NY ) + Y(LL)%V => YT(1:sNX ,1:sNY ) + Y(LR)%V => YT(2:sNX+1,1:sNY ) + Y(UR)%V => YT(2:sNX+1,2:sNY+1) + Y(UL)%V => YT(1:sNX ,2:sNY+1) ! Allocate space for contigous vertices of one face !-------------------------------------------------- - allocate(Xv(6*(NX-1),NY-1,4),stat=STATUS); VERIFY_(STATUS) - allocate(Yv(6*(NX-1),NY-1,4),stat=STATUS); VERIFY_(STATUS) + allocate(Xv(nCPU*sNX,sNY,4),stat=STATUS); VERIFY_(STATUS) + allocate(Yv(nCPU*sNX,sNY,4),stat=STATUS); VERIFY_(STATUS) + XV = 0.0 + YV = 0.0 + + KF = 0 + KP = 0 FACES: do K=1,NFACES + write(facefile,"(A,I3.3,A)") 'tile',K,'.mitgrid' + if(Verb) then + print *, trim(facefile) + end if + + + +! Allocate space for symmetric version of coordinates +!---------------------------------------------------- + + allocate(rA(scaleX(k)*NX+1, scaleY(k)*NY+1),stat=STATUS) + VERIFY_(STATUS) + allocate(XG(scaleX(k)*NX+1, scaleY(k)*NY+1),stat=STATUS) + VERIFY_(STATUS) + allocate(YG(scaleX(k)*NX+1, scaleY(k)*NY+1),stat=STATUS) + VERIFY_(STATUS) + + xg=0.0 + yg=0.0 + + LENGTH = size(XG)*rkind ! Read vertcies for each face !---------------------------- - open (IUNIT, FILE=trim(GridDir)//trim(FACEFILE(k)), & - ACCESS='DIRECT', RECL=LENGTH, STATUS='OLD') + open (IUNIT, FILE=trim(GridDir)//trim(FACEFILE), & + ACCESS='DIRECT', RECL=LENGTH, STATUS='OLD',convert='big_endian') + read (IUNIT,REC=5) rA read (IUNIT,REC=6) XG read (IUNIT,REC=7) YG +#if 1 +! areamin = 1.e15 + do i=1,size(xg,1) + do j=1,size(xg,2) + if (rA(i,j) <=0.0) cycle +! areamin = min(areamin,rA(i,j)) +! xc = (XG(i,j)+XG(i+1,j))/2 +! yc = (YG(i,j)+YG(i+1,j))/2 + xc = XG(i,j) + yc = YG(i,j) + write(*,"(f6.1,a1,f6.1,a1,i3)") xc,",",yc,",", nint(100*rA(i,j)/11896090857.) + end do + end do +#endif + close(IUNIT) if(Verb) then - print * - print *, 'Processing face ', K - print *, 'MAXVAL(XG), MINVAL(XG) = ', maxval(XG), minval(XG) - print *, 'MAXVAL(YG), MINVAL(YG) = ', maxval(YG), minval(YG) - endif - - IBEG = 1 + (NX-1)*(K-1) - IEND = (NX-1)*(K ) - -! Copy face corners into contiguous array expected by LRrasterize -!---------------------------------------------------------------- - - CORNERS: do N=1,4 - XV(IBEG:IEND,:,N) = X(N)%V - YV(IBEG:IEND,:,N) = Y(N)%V - end do CORNERS + PRINT *, 'MIN/MAXVAL(XG) = ', MINVAL(XG), MAXVAL(XG) + PRINT *, 'MIN/MAXVAL(YG) = ', MINVAL(YG), MAXVAL(YG) + PRINT *, 'MAXVAL(rA) = ', MAXVAL(rA) + end if + DO J = 1, scaleY(k)*pNY + DO I = 1, scaleX(k)*pNX + KF = KF + 1 + ! check if KF is in the blackList. If YES, skip + haveIt = .false. + DO L = 1, BLNKSZ + if (blanklist(L) > KF) exit + if (blanklist(L) == KF) then + haveIt = .true. + exit + end if + END DO + if (haveIt) then +! if(Verb) then +! print *, 'skipping ',kf +! end if + cycle + end if + KP = KP + 1 + + I1 = (I-1)*sNX + 1 + IN = I *sNX + 1 + J1 = (J-1)*sNY + 1 + JN = J *sNY + 1 + XT = XG(I1:IN,J1:JN) + YT = YG(I1:IN,J1:JN) + + IBEG = 1 + sNX*(KP-1) + IEND = sNX*(KP ) + + ! Copy face corners into contiguous array expected by LRrasterize + !---------------------------------------------------------------- + + CORNERS: do N=1,4 + XV(IBEG:IEND,:,N) = X(N)%V + YV(IBEG:IEND,:,N) = Y(N)%V + end do CORNERS + + END DO + END DO + deallocate(YG) + deallocate(XG) end do FACES + if(Verb) then + print *,'KP=',kp + end if + STOP + +! open(unit=9, file='mit-llc1080.ascii', form='formatted', status='new') +! write(9,*) XV(:,:,1) +! write(9,*) YV(:,:,1) +! close(9) +! stop 'writing coordinates only, exiting...' - call LRRasterize(RASTERFILE,XV,YV,nc=nc,nr=nr,& - SurfaceType=0,Verb=Verb) + call LRRasterize(rasterFile,xv,yv,nc=ncol,nr=nrow,& + SurfaceType=0,Verb=Verb) call exit(0) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMOMAquaRaster.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMOMAquaRaster.F90 index 7e6fbe4ea..023f2bd26 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMOMAquaRaster.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMOMAquaRaster.F90 @@ -35,6 +35,7 @@ program MOMraster integer :: Nc = 8640 integer :: NR = 4320 + REAL_ :: tol INCLUDE "netcdf.inc" ! Process Arguments @@ -102,8 +103,12 @@ program MOMraster ! Get surface types from integer raster file + tol = 1.0e-12 ! the default for the rasterization routine + !Atanas: some heuristics for very coarse MOM grids + if (nr * (180/jm) > 55000) tol = 1.0e-5 + call LRRasterize(GridName,xvert,yvert,nc=nc,nr=nr,& - SurfaceType=0,Verb=Verb,Here=Here) + SurfaceType=0,Verb=Verb,Here=Here,tol=tol) call exit(0) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rasterize.H b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rasterize.H index 7a892ac58..e8c6bbde0 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rasterize.H +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/rasterize.H @@ -13,7 +13,7 @@ ! !IROUTINE: LRRasterize -- Rasterizes a 2-D array of polygons. subroutine LRRasterize2File(GridName, xv,yv,nc,nr,xmn,xmx,ymn,ymx, & - SurfaceType, Verb, Here,jseg ) + SurfaceType, Verb, Here,jseg, tol ) ! This routine rasterizes a grid defined by a 2-D array of polygons. ! The raster value assigned each pixel is either sign((I*pushleft + J),sgn), @@ -70,6 +70,7 @@ logical, optional, intent(IN) :: here ! write here integer, optional, intent(IN) :: SurfaceType integer, optional, intent(IN) :: jseg + REAL_, optional :: tol character*(128) :: TileFile character*(128) :: TilDir='', RstDir='' @@ -136,7 +137,7 @@ call LRRasterize2Mem (Raster, xv, yv, TileFile, & xmn, xmx, ymn, ymx, & - SurfaceType, verb, jseg ) + SurfaceType, verb, jseg, tol ) ! Make sure it worked !-------------------- @@ -171,7 +172,7 @@ subroutine LRRasterize2Mem(Raster,xv,yv,Tilefile, & xmn,xmx,ymn,ymx, & - SurfaceType,verb,jseg ) + SurfaceType,verb,jseg, tol ) ! This routine rasterizes a grid defined by a 2-D array of polygons. ! The raster value assigned is an index to the table. @@ -205,6 +206,7 @@ logical, optional, intent(IN) :: verb ! Verbose integer, optional, intent(IN) :: SurfaceType integer, optional, intent(IN) :: jseg + REAL_, optional :: tol ! X abd Y bounds of each polygon @@ -243,9 +245,15 @@ :: xvc, yvc, xvs, yvs, xrd, yrd, x3, y3, z3, & dx3, dy3, dz3, x31, x32, y31, y32, z31, z32, & dx4, dy4, x4, y4, xu, yu + REAL_ :: tol_ ! Process optionals + tol_ = 1.0e-12 + if (present(tol)) then + tol_ = tol + end if + if(present(jseg)) then useg = jseg else @@ -622,7 +630,7 @@ y0 = ycs(jj)*xss(ii) do n=1,NV - Isin = (x0*z31(n) + y0*x31(n) + yss(jj)*y31(n) - dx3(n)) <= 1.e-12 + Isin = (x0*z31(n) + y0*x31(n) + yss(jj)*y31(n) - dx3(n)) <= tol_ if(.not.IsIn) exit end do From 1d374a338fe93e9dcb1631fb526c02750350879f Mon Sep 17 00:00:00 2001 From: Atanas Trayanov Date: Tue, 8 Nov 2022 20:56:51 -0500 Subject: [PATCH 53/77] Fixed syntax --- .../GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 index 47b7e25b2..c6d6f887b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 @@ -148,7 +148,7 @@ program MAIN GridDir = arg blanklist = 0 - OPEN(UNIT=iUnit, name='data.exch2', form='formatted', status='old') + OPEN(UNIT=iUnit, file='data.exch2', form='formatted', status='old') READ(UNIT=iUnit,NML=W2_EXCH2_PARM01) CLOSE(iUnit) BLNKSZ = count(blanklist /= 0) From 3a241aa1b2c86182e3b2cd934a3d7d9ea14507c4 Mon Sep 17 00:00:00 2001 From: Atanas Trayanov Date: Wed, 9 Nov 2022 10:13:00 -0500 Subject: [PATCH 54/77] Replaced iargc and getarc with standard compliant calls --- .../GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 index c6d6f887b..e2a64a68c 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMITAquaRaster.F90 @@ -107,7 +107,7 @@ program MAIN ! Get source grid directory and destination raster file names !------------------------------------------------------------ - i = iargc() + i = command_argument_count() if(I < 2 .or. i > 7) then print *, "Wrong Number of arguments: ", i @@ -116,13 +116,13 @@ program MAIN end if nxt = 1 - call getarg(nxt,arg) + call get_command_argument(nxt,arg) do while(arg(1:1)=='-') opt=arg(2:2) if(len(trim(arg))==2) then if(scan(opt,'zv')==0) then nxt = nxt + 1 - call getarg(nxt,arg) + call get_command_argument(nxt,arg) endif else arg = arg(3:) @@ -142,7 +142,7 @@ program MAIN call exit(1) end select nxt = nxt + 1 - call getarg(nxt,arg) + call get_command_argument(nxt,arg) end do GridDir = arg From 91d0d5d93e510e7f00617eec43035d29a9707e9a Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Thu, 10 Nov 2022 06:12:26 -0500 Subject: [PATCH 55/77] additional clean-up of snow albedo changes - removed obsolete checks for unphysical snow albedo values from Catch GC - editedd comments - fixed indentation in subroutine MODIS_snow_alb() --- .../GEOS_CatchCNGridComp.F90 | 2 +- .../GEOScatch_GridComp/GEOS_CatchGridComp.F90 | 36 +- .../Shared/GEOS_SurfaceGridComp.rc | 6 +- .../Utils/Raster/mod_process_hres_data.F90 | 446 +++++++++--------- .../Utils/mk_restarts/CatchmentRst.F90 | 6 +- 5 files changed, 250 insertions(+), 246 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 index 4bc2943fc..a2bbcb990 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatchCN_GridComp/GEOS_CatchCNGridComp.F90 @@ -86,7 +86,7 @@ subroutine SetServices ( GC, RC ) ! SNOW ALBEDO -- so far, only parameterization based on look-up table is implemented for CatchCN ! 0 : parameterization based on look-up table - ! 1 : MODIS-derived snow albedo (where available, elsewhere no data values filled with global land average Snow_Albedo=0.56) + ! 1 : MODIS-derived snow albedo (backfilled with global land average snow albedo) call ESMF_ConfigGetAttribute (SCF, label='SNOW_ALBEDO_INFO:', value=SNOW_ALBEDO_INFO, DEFAULT=0, RC=STATUS) ; VERIFY_(STATUS) _ASSERT( SNOW_ALBEDO_INFO==0, "SNOW_ALBEDO_INFO must be 0 for CatchCN") diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 index c4b6f33c9..257ac7bc7 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/GEOS_CatchGridComp.F90 @@ -230,7 +230,7 @@ subroutine SetServices ( GC, RC ) ! SNOW ALBEDO ! 0 : parameterization based on look-up table - ! 1 : MODIS-derived snow albedo (where available, elsewhere no data values filled with global land average Snow_Albedo=0.56) + ! 1 : MODIS-derived snow albedo (backfilled with global land average snow albedo) call MAPL_GetResource (SCF, SNOW_ALBEDO_INFO, label='SNOW_ALBEDO_INFO:', DEFAULT=0, __RC__ ) ! GOSWIM SNOW_ALBEDO @@ -4877,16 +4877,17 @@ subroutine Driver ( RC ) if (SNOW_ALBEDO_INFO == 1) then - ! where available, use MODIS-derived snow albedo from bcs (via Catch restart) - + ! use MODIS-derived snow albedo from bcs (via Catch restart) + ! + ! as a restart parameter from the bcs, snow albedo must not have no-data-values + ! (checks for unphysical values should be in the make_bcs package) + call MAPL_GetPointer(INTERNAL,SNOWALB,'SNOWALB',RC=STATUS); VERIFY_(STATUS) - where (SNOWALB > 0. .and. SNOWALB <= 1.) - SNOVR = SNOWALB - SNONR = SNOWALB - SNOVF = SNOWALB - SNONF = SNOWALB - endwhere + SNOVR = SNOWALB + SNONR = SNOWALB + SNOVF = SNOWALB + SNONF = SNOWALB endif @@ -5570,14 +5571,15 @@ subroutine Driver ( RC ) if (SNOW_ALBEDO_INFO == 1) then - ! where available, use MODIS-derived snow albedo from bcs (via Catch restart) - - where (SNOWALB > 0. .and. SNOWALB <= 1.) - SNOVR = SNOWALB - SNONR = SNOWALB - SNOVF = SNOWALB - SNONF = SNOWALB - endwhere + ! use MODIS-derived snow albedo from bcs (via Catch restart) + ! + ! as a restart parameter from the bcs, snow albedo must not have no-data-values + ! (checks for unphysical values should be in the make_bcs package) + + SNOVR = SNOWALB + SNONR = SNOWALB + SNOVF = SNOWALB + SNONF = SNOWALB endif diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc index 282985451..1c11a0be2 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Shared/GEOS_SurfaceGridComp.rc @@ -117,8 +117,10 @@ # ---- SNOW ALBEDO # # 0 : Snow albedo parameterization based on look-up table (default) -# 1 : Snow albedo derived from MODIS Collection MOD10A1.061 (Feb/2000 - Mar/2022) [NOT YET AVAILABLE FOR CatchCN] -# where available, elsewhere no data values filled with global land average Snow_Albedo=0.56 +# 1 : Snow albedo derived from MODIS Collection MOD10A1.061 (Feb/2000 - Mar/2022) +# - backfilled with global land average snow albedo where unavailable +# - must use compatible bcs version (e.g., v06, v08, v09) +# - NOT YET AVAILABLE FOR CatchCN # # GEOSagcm=>SNOW_ALBEDO_INFO: 0 # GEOSldas=>SNOW_ALBEDO_INFO: 0 diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index ff39c6c7b..8630ca216 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -2995,238 +2995,238 @@ END SUBROUTINE hres_gswp2 SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) - ! Process static snow albedo calculated from MODIS climatology and write into clsm/catch_params.nc4 - ! - ! Biljana Orescanin July 2022, SSAI@NASA - - implicit none - integer, intent (in) :: nx, ny - character(*) :: gfiler - integer,allocatable,target,dimension (:,:) :: tile_id - - character*200 :: fname - character*2 :: vv,hh - integer :: n,maxcat,j,ncid,status - real,allocatable,dimension(:) :: min_lon,max_lon,min_lat,max_lat,snw_alb - integer(kind=4),parameter :: xdim = 1200, ydim = 1200 - real,parameter :: alb_res=10.0/1200.0 - real,dimension(xdim,ydim) :: stch_snw_alb_tmp - real,dimension(36,18,xdim,ydim) :: stch_snw_alb - real :: minlon,maxlon,minlat,maxlat,pad_lon,pad_lat - real :: sno_alb_cnt,sno_alb_sum,sno_alb_cnt2,sno_alb_sum2 - integer :: vvtil_min,hhtil_min,vvtil_max,hhtil_max,hhtil,vvtil - integer :: tindex1,pfaf1 - integer(kind=4) :: dummy,varid1 - integer(kind=4) :: imin,imax,jmin,jmax - integer(kind=4) :: imin2,imax2,jmin2,jmax2,count_init_invalid - logical :: file_exists - - ! Read number of catchment-tiles (maxcat) from catchment.def file - fname='clsm/catchment.def' - open (10,file=fname,status='old',action='read',form='formatted') - read(10,*) maxcat - - ! Read min/max lat/lons to use when locating snow albedo grids in - ! the stitched MODIS albedo file - allocate (min_lon(1:maxcat)) - allocate (min_lat(1:maxcat)) - allocate (max_lon(1:maxcat)) - allocate (max_lat(1:maxcat)) - allocate (snw_alb(1:maxcat)) - - ! Start by setting all snow albedo values to missing - snw_alb(:)=MAPL_UNDEF - - do n = 1, maxcat - read (10,*) tindex1,pfaf1,minlon,maxlon,minlat,maxlat - min_lon(n) = minlon - max_lon(n) = maxlon - min_lat(n) = minlat - max_lat(n) = maxlat - end do - - close (10,status='keep') - - ! Read tile-id raster file - allocate(tile_id(1:nx,1:ny)) - - fname=trim(gfiler)//'.rst' - open (10,file=fname,status='old',action='read', & - form='unformatted',convert='little_endian') - - do j=1,ny - read(10)tile_id(:,j) - end do - - close (10,status='keep') - - !------------ Get the information on snow albedo ----- - ! ----------- The information on snow albedo is stored in 10x10deg 30-arcsec resolution files. - ! ----------- Read in this information, then loop over the tiles to find a corresponding snow albedo. - - ! Read in all 10x10deg snow albedo files into a single [36,18,1200,1200] array - do hhtil=1,36 ! loop over input files - horizontal direction - do vvtil=1,18 ! loop over input files - vertical direction - - write(vv,'(i2.2)') vvtil - write(hh,'(i2.2)') hhtil - - ! MODIS-based climatology albedo raster files filled for NoData values using global land - ! average Snow Albedo (0.56). Note: the average excludes Antarctica and Greenland ice - ! sheets and is weighted by the grid-cell area. - fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v2/snow_alb_FillVal_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' - - ! MODIS-based climatology albedo raster files (NoData set to 1e+15) - !fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v1/snow_alb_noFill_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' - - ! Open the file. (NF90_NOWRITE ensures read-only access to the file) - status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) - ! Based on vars name, get the varids. - status=NF_INQ_VARID(ncid,'Snow_Albedo',VarID1) ; VERIFY_(STATUS) - ! Read the data. - status=NF_GET_VARA_REAL(ncid,VarID1,(/1,1/),(/xdim,ydim/),stch_snw_alb_tmp) ; VERIFY_(STATUS) - ! Close the file, freeing all resources. - status=NF_CLOSE(ncid); VERIFY_(STATUS) - - ! Store snow albedo values into a single 4D aray - stch_snw_alb(hhtil,vvtil,:,:)=stch_snw_alb_tmp - + ! Process static snow albedo calculated from MODIS climatology and write into clsm/catch_params.nc4 + ! + ! Biljana Orescanin July 2022, SSAI@NASA + + implicit none + integer, intent (in) :: nx, ny + character(*) :: gfiler + integer,allocatable,target,dimension (:,:) :: tile_id + + character*200 :: fname + character*2 :: vv,hh + integer :: n,maxcat,j,ncid,status + real,allocatable,dimension(:) :: min_lon,max_lon,min_lat,max_lat,snw_alb + integer(kind=4),parameter :: xdim = 1200, ydim = 1200 + real,parameter :: alb_res=10.0/1200.0 + real,dimension(xdim,ydim) :: stch_snw_alb_tmp + real,dimension(36,18,xdim,ydim) :: stch_snw_alb + real :: minlon,maxlon,minlat,maxlat,pad_lon,pad_lat + real :: sno_alb_cnt,sno_alb_sum,sno_alb_cnt2,sno_alb_sum2 + integer :: vvtil_min,hhtil_min,vvtil_max,hhtil_max,hhtil,vvtil + integer :: tindex1,pfaf1 + integer(kind=4) :: dummy,varid1 + integer(kind=4) :: imin,imax,jmin,jmax + integer(kind=4) :: imin2,imax2,jmin2,jmax2,count_init_invalid + logical :: file_exists + + ! Read number of catchment-tiles (maxcat) from catchment.def file + fname='clsm/catchment.def' + open (10,file=fname,status='old',action='read',form='formatted') + read(10,*) maxcat + + ! Read min/max lat/lons to use when locating snow albedo grids in + ! the stitched MODIS albedo file + allocate (min_lon(1:maxcat)) + allocate (min_lat(1:maxcat)) + allocate (max_lon(1:maxcat)) + allocate (max_lat(1:maxcat)) + allocate (snw_alb(1:maxcat)) + + ! Start by setting all snow albedo values to missing + snw_alb(:)=MAPL_UNDEF + + do n = 1, maxcat + read (10,*) tindex1,pfaf1,minlon,maxlon,minlat,maxlat + min_lon(n) = minlon + max_lon(n) = maxlon + min_lat(n) = minlat + max_lat(n) = maxlat + end do + + close (10,status='keep') + + ! Read tile-id raster file + allocate(tile_id(1:nx,1:ny)) + + fname=trim(gfiler)//'.rst' + open (10,file=fname,status='old',action='read', & + form='unformatted',convert='little_endian') + + do j=1,ny + read(10)tile_id(:,j) + end do + + close (10,status='keep') + + !------------ Get the information on snow albedo ----- + ! ----------- The information on snow albedo is stored in 10x10deg 30-arcsec resolution files. + ! ----------- Read in this information, then loop over the tiles to find a corresponding snow albedo. + + ! Read in all 10x10deg snow albedo files into a single [36,18,1200,1200] array + do hhtil=1,36 ! loop over input files - horizontal direction + do vvtil=1,18 ! loop over input files - vertical direction + + write(vv,'(i2.2)') vvtil + write(hh,'(i2.2)') hhtil + + ! MODIS-based climatology albedo raster files, backfilled with global land + ! average snow albedo (=0.56; average excludes Antarctica and Greenland ice + ! sheets and is weighted by the grid-cell area). + fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v2/snow_alb_FillVal_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' + + ! MODIS-based climatology albedo raster files (NoData set to 1e+15) + !fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v1/snow_alb_noFill_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' + + ! Open the file. (NF90_NOWRITE ensures read-only access to the file) + status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) + ! Based on vars name, get the varids. + status=NF_INQ_VARID(ncid,'Snow_Albedo',VarID1) ; VERIFY_(STATUS) + ! Read the data. + status=NF_GET_VARA_REAL(ncid,VarID1,(/1,1/),(/xdim,ydim/),stch_snw_alb_tmp) ; VERIFY_(STATUS) + ! Close the file, freeing all resources. + status=NF_CLOSE(ncid); VERIFY_(STATUS) + + ! Store snow albedo values into a single 4D aray + stch_snw_alb(hhtil,vvtil,:,:)=stch_snw_alb_tmp + + enddo enddo - enddo - - ! loop over tiles - print*, 'Starting tile loop for snow albedo. ' - count_init_invalid=0 ! counter for non-valid snow albedo values (informational use only) - - do n = 1, maxcat ! loop over tiles - - ! Set sums and counts to zero - sno_alb_sum =0. - sno_alb_cnt =0. - sno_alb_sum2=0. - sno_alb_cnt2=0. - - ! Use tile's min/max lat/lon info to identify the 10x10deg input file(s) - ! and read in snow albedo value(s). The "ceiling" and "floor" implements the "halo". - vvtil_min= floor((min_lat(n)+ 90.0)/10.)+1 - hhtil_min= floor((min_lon(n)+180.0)/10.)+1 - - ! if tile crosses the edge of the snow albedo 10x10deg box, expand the - ! search area into the neighbouring 10x10deg box - hhtil_max=hhtil_min - vvtil_max=vvtil_min - if (floor(min_lon(n)/10) .ne. floor(max_lon(n)/10)) hhtil_max=hhtil_min+1 - if (floor(min_lat(n)/10) .ne. floor(max_lat(n)/10)) vvtil_max=vvtil_min+1 - - ! Safety checks: - ! 1. Make sure vv's and hh's are within the range. If min>max, swap them. - if (vvtil_min .gt. vvtil_max) then - dummy =vvtil_min - vvtil_min=vvtil_max - vvtil_max=dummy - endif - if (hhtil_min .gt. hhtil_max) then - dummy =hhtil_min - hhtil_min=hhtil_max - hhtil_max=dummy - endif - - ! 2. Keep within the range. - vvtil_min=max(vvtil_min,1) - vvtil_max=min(vvtil_max,18) - hhtil_min=max(hhtil_min,1) - hhtil_max=min(hhtil_max,36) - - do hhtil=hhtil_min,hhtil_max ! loop through input files - horizontal direction - do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction - - ! Find indices ranges corresponding to the current tile area. - imin=floor((min_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 - imax=floor((max_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 - jmin=floor((min_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 - jmax=floor((max_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 - ! Keep within the range. - imin=max(imin,1) - imax=min(imax,xdim) - jmin=max(jmin,1) - jmax=min(jmax,ydim) - - ! Generate sums and counts using current tile corresponding indices - sno_alb_sum= sno_alb_sum + & - sum(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax), & - stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & - stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).le.1.0) - - sno_alb_cnt= sno_alb_cnt + & - count(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & - stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).le.1.0) - - end do ! vvtil - end do ! hhtil - - ! Calculate snow albedo for the current tile - snw_alb(n) = sno_alb_sum / max(1.0,sno_alb_cnt) - if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=MAPL_UNDEF !1.E15 - - ! If no valid solution found, and if tile size smaller than snow albedo resolution, - ! expand search area by 1-tile padding. - - ! Size of a tile (in both directions) - pad_lon=(max_lon(n)-min_lon(n)) - pad_lat=(max_lat(n)-min_lat(n)) - - if (snw_alb(n) .le. 0.0 .and. (pad_lon .lt. alb_res .or. pad_lat .lt. alb_res)) then - - count_init_invalid=count_init_invalid+1 - - do hhtil=hhtil_min,hhtil_max ! loop through input files - horizontal direction - do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction - - ! Repeat the steps for extracting snow albedo value - imin2=floor((min_lon(n)-pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0))+1 - imax2=floor((max_lon(n)+pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0))+1 - jmin2=floor((min_lat(n)-pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0))+1 - jmax2=floor((max_lat(n)+pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0))+1 - imin2=max(imin2,1) - imax2=min(imax2,xdim) - jmin2=max(jmin2,1) - jmax2=min(jmax2,ydim) - - sno_alb_sum2= sno_alb_sum2 + & - sum(stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2), & - stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & - stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).le.1.0) - - sno_alb_cnt2= sno_alb_cnt2 + & - count(stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & - stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).le.1.0) - - end do ! vvtil - end do ! hhtil - - snw_alb(n) = sno_alb_sum2 / max(1.0,sno_alb_cnt2) - if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=MAPL_UNDEF !1.E15 - - endif - - end do ! n-loop over tiles - - ! write snow albedo into clsm/catch_params.nc4 + + ! loop over tiles + print*, 'Starting tile loop for snow albedo. ' + count_init_invalid=0 ! counter for non-valid snow albedo values (informational use only) + + do n = 1, maxcat ! loop over tiles + + ! Set sums and counts to zero + sno_alb_sum =0. + sno_alb_cnt =0. + sno_alb_sum2=0. + sno_alb_cnt2=0. + + ! Use tile's min/max lat/lon info to identify the 10x10deg input file(s) + ! and read in snow albedo value(s). The "ceiling" and "floor" implements the "halo". + vvtil_min= floor((min_lat(n)+ 90.0)/10.)+1 + hhtil_min= floor((min_lon(n)+180.0)/10.)+1 + + ! if tile crosses the edge of the snow albedo 10x10deg box, expand the + ! search area into the neighbouring 10x10deg box + hhtil_max=hhtil_min + vvtil_max=vvtil_min + if (floor(min_lon(n)/10) .ne. floor(max_lon(n)/10)) hhtil_max=hhtil_min+1 + if (floor(min_lat(n)/10) .ne. floor(max_lat(n)/10)) vvtil_max=vvtil_min+1 + + ! Safety checks: + ! 1. Make sure vv's and hh's are within the range. If min>max, swap them. + if (vvtil_min .gt. vvtil_max) then + dummy =vvtil_min + vvtil_min=vvtil_max + vvtil_max=dummy + endif + if (hhtil_min .gt. hhtil_max) then + dummy =hhtil_min + hhtil_min=hhtil_max + hhtil_max=dummy + endif + + ! 2. Keep within the range. + vvtil_min=max(vvtil_min,1) + vvtil_max=min(vvtil_max,18) + hhtil_min=max(hhtil_min,1) + hhtil_max=min(hhtil_max,36) + + do hhtil=hhtil_min,hhtil_max ! loop through input files - horizontal direction + do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction + + ! Find indices ranges corresponding to the current tile area. + imin=floor((min_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 + imax=floor((max_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 + jmin=floor((min_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 + jmax=floor((max_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 + ! Keep within the range. + imin=max(imin,1) + imax=min(imax,xdim) + jmin=max(jmin,1) + jmax=min(jmax,ydim) + + ! Generate sums and counts using current tile corresponding indices + sno_alb_sum= sno_alb_sum + & + sum(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax), & + stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & + stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).le.1.0) + + sno_alb_cnt= sno_alb_cnt + & + count(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & + stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).le.1.0) + + end do ! vvtil + end do ! hhtil + + ! Calculate snow albedo for the current tile + snw_alb(n) = sno_alb_sum / max(1.0,sno_alb_cnt) + if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=MAPL_UNDEF !1.E15 + + ! If no valid solution found, and if tile size smaller than snow albedo resolution, + ! expand search area by 1-tile padding. + + ! Size of a tile (in both directions) + pad_lon=(max_lon(n)-min_lon(n)) + pad_lat=(max_lat(n)-min_lat(n)) + + if (snw_alb(n) .le. 0.0 .and. (pad_lon .lt. alb_res .or. pad_lat .lt. alb_res)) then + + count_init_invalid=count_init_invalid+1 + + do hhtil=hhtil_min,hhtil_max ! loop through input files - horizontal direction + do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction + + ! Repeat the steps for extracting snow albedo value + imin2=floor((min_lon(n)-pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0))+1 + imax2=floor((max_lon(n)+pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0))+1 + jmin2=floor((min_lat(n)-pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0))+1 + jmax2=floor((max_lat(n)+pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0))+1 + imin2=max(imin2,1) + imax2=min(imax2,xdim) + jmin2=max(jmin2,1) + jmax2=min(jmax2,ydim) + + sno_alb_sum2= sno_alb_sum2 + & + sum(stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2), & + stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & + stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).le.1.0) + + sno_alb_cnt2= sno_alb_cnt2 + & + count(stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & + stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).le.1.0) + + end do ! vvtil + end do ! hhtil + + snw_alb(n) = sno_alb_sum2 / max(1.0,sno_alb_cnt2) + if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=MAPL_UNDEF !1.E15 + + endif + + end do ! n-loop over tiles + + ! write snow albedo into clsm/catch_params.nc4 inquire(file='clsm/catch_params.nc4', exist=file_exists) - + if(file_exists) then status = NF_OPEN ('clsm/catch_params.nc4', NF_WRITE, ncid ) ; VERIFY_(STATUS) status = NF_PUT_VARA_REAL(NCID,NC_VarID(NCID,'SNOWALB'),(/1/),(/maxcat/),real(snw_alb)) ; VERIFY_(STATUS) STATUS = NF_CLOSE (NCID) ; VERIFY_(STATUS) endif - - print*, 'Ended tile loop for snow albedo. ' - print*, 'Initially found ', count_init_invalid, ' tiles with no-data values for snow albedo (out of ', maxcat,')' - + + print*, 'Ended tile loop for snow albedo. ' + print*, 'Initially found ', count_init_invalid, ' tiles with no-data values for snow albedo (out of ', maxcat,')' + END SUBROUTINE MODIS_snow_alb - + !-------------------------------------------------------------------------------------- - + SUBROUTINE soil_para_hwsd (nx,ny,gfiler) ! Processing NGDC-HWSD-STATSGO merged soil properties with Woesten Soil diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index 40b9b03ef..34406b852 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -336,7 +336,7 @@ subroutine read_shared_nc4(this, formatter, rc) call MAPL_VarRead(formatter,"WW",this%ww, __RC__) endif _RETURN(_SUCCESS) - end subroutine + end subroutine read_shared_nc4 subroutine write_nc4 (this, filename, rc) class(CatchmentRst), intent(inout):: this @@ -522,7 +522,7 @@ subroutine allocate_catch(this,rc) _RETURN(_SUCCESS) end subroutine allocate_catch - ! This subroutine reads BCs from BCSDIR and hydrological varable + ! This subroutine reads BCs from BCSDIR and hydrological variable (??) subroutine add_bcs_to_rst(this, surflay, DataDir, rc) class(CatchmentRst), intent(inout) :: this real, intent(in) :: surflay @@ -542,7 +542,7 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) type(Variable) :: var type(FileMetadata) :: meta_ - character*256 :: Iam = "add_bcs" + character*256 :: Iam = "add_bcs_to_rst" ntiles = this%ntiles From b9b84ffc94cb759ffa2336ee4534af98501037e7 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Thu, 10 Nov 2022 17:37:30 -0500 Subject: [PATCH 56/77] removed obsolete reading of tile_id from subroutine MODIS_snow_alb() --- .../Utils/Raster/mod_process_hres_data.F90 | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index 8630ca216..bea879c9f 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -2993,16 +2993,13 @@ END SUBROUTINE hres_gswp2 !---------------------------------------------------------------------- - SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) + SUBROUTINE MODIS_snow_alb ( ) ! Process static snow albedo calculated from MODIS climatology and write into clsm/catch_params.nc4 ! ! Biljana Orescanin July 2022, SSAI@NASA implicit none - integer, intent (in) :: nx, ny - character(*) :: gfiler - integer,allocatable,target,dimension (:,:) :: tile_id character*200 :: fname character*2 :: vv,hh @@ -3047,19 +3044,6 @@ SUBROUTINE MODIS_snow_alb (nx,ny,gfiler) close (10,status='keep') - ! Read tile-id raster file - allocate(tile_id(1:nx,1:ny)) - - fname=trim(gfiler)//'.rst' - open (10,file=fname,status='old',action='read', & - form='unformatted',convert='little_endian') - - do j=1,ny - read(10)tile_id(:,j) - end do - - close (10,status='keep') - !------------ Get the information on snow albedo ----- ! ----------- The information on snow albedo is stored in 10x10deg 30-arcsec resolution files. ! ----------- Read in this information, then loop over the tiles to find a corresponding snow albedo. From e96a4ce41d6d1e4a213fb1e2ba33cb27542f4425 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Thu, 10 Nov 2022 17:40:47 -0500 Subject: [PATCH 57/77] fixed call to subroutine MODIS_snow_alb() [see previous commit] --- .../GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 index b88cd2fa2..e163fb2d5 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkCatchParam.F90 @@ -661,7 +661,7 @@ PROGRAM mkCatchParam tmpstring = 'Step 14: Static snow albedo from MODIS' write (log_file,'(a)') trim(tmpstring) write (log_file,'(a)')' Creating file...' - call MODIS_snow_alb (nc,nr,gridnamer) + call MODIS_snow_alb ( ) write (log_file,'(a)')' Done.' write (log_file,'(a)')' ' endif From dffe4ff42986385a817c6e0ba46bde2ea385af79 Mon Sep 17 00:00:00 2001 From: Atanas Trayanov Date: Thu, 10 Nov 2022 21:15:22 -0500 Subject: [PATCH 58/77] Simplified the expresion to avoid integer division issues --- .../GEOSsurface_GridComp/Utils/Raster/mkMOMAquaRaster.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMOMAquaRaster.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMOMAquaRaster.F90 index 023f2bd26..4f7dff4a1 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMOMAquaRaster.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mkMOMAquaRaster.F90 @@ -105,7 +105,7 @@ program MOMraster tol = 1.0e-12 ! the default for the rasterization routine !Atanas: some heuristics for very coarse MOM grids - if (nr * (180/jm) > 55000) tol = 1.0e-5 + if (nr > 300*jm) tol = 1.0e-5 call LRRasterize(GridName,xvert,yvert,nc=nc,nr=nr,& SurfaceType=0,Verb=Verb,Here=Here,tol=tol) From 7bff94341bdd0cf7138c1cf1cc52d829918add07 Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Sun, 13 Nov 2022 21:22:09 -0500 Subject: [PATCH 59/77] updated to use just filled raster files --- .../Utils/Raster/mod_process_hres_data.F90 | 175 ++++++------------ 1 file changed, 58 insertions(+), 117 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index bea879c9f..eba91c7f5 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -3003,19 +3003,16 @@ SUBROUTINE MODIS_snow_alb ( ) character*200 :: fname character*2 :: vv,hh - integer :: n,maxcat,j,ncid,status + integer :: n,maxcat,ncid,status real,allocatable,dimension(:) :: min_lon,max_lon,min_lat,max_lat,snw_alb integer(kind=4),parameter :: xdim = 1200, ydim = 1200 - real,parameter :: alb_res=10.0/1200.0 real,dimension(xdim,ydim) :: stch_snw_alb_tmp real,dimension(36,18,xdim,ydim) :: stch_snw_alb - real :: minlon,maxlon,minlat,maxlat,pad_lon,pad_lat - real :: sno_alb_cnt,sno_alb_sum,sno_alb_cnt2,sno_alb_sum2 + real :: minlon,maxlon,minlat,maxlat + real :: sno_alb_cnt,sno_alb_sum integer :: vvtil_min,hhtil_min,vvtil_max,hhtil_max,hhtil,vvtil integer :: tindex1,pfaf1 - integer(kind=4) :: dummy,varid1 - integer(kind=4) :: imin,imax,jmin,jmax - integer(kind=4) :: imin2,imax2,jmin2,jmax2,count_init_invalid + integer(kind=4) :: imin,imax,jmin,jmax,varid1 logical :: file_exists ! Read number of catchment-tiles (maxcat) from catchment.def file @@ -3077,122 +3074,67 @@ SUBROUTINE MODIS_snow_alb ( ) enddo enddo + + if (minval(stch_snw_alb) .le. 0.0 .or. maxval(stch_snw_alb) .gt. 1.0) then + print*, 'There is a problem with snow albedo raster file. Non-physical values present. STOP!' + stop + endif ! loop over tiles - print*, 'Starting tile loop for snow albedo. ' - count_init_invalid=0 ! counter for non-valid snow albedo values (informational use only) + print*, 'Starting tile loop for snow albedo.' do n = 1, maxcat ! loop over tiles - - ! Set sums and counts to zero - sno_alb_sum =0. - sno_alb_cnt =0. - sno_alb_sum2=0. - sno_alb_cnt2=0. - - ! Use tile's min/max lat/lon info to identify the 10x10deg input file(s) - ! and read in snow albedo value(s). The "ceiling" and "floor" implements the "halo". - vvtil_min= floor((min_lat(n)+ 90.0)/10.)+1 - hhtil_min= floor((min_lon(n)+180.0)/10.)+1 - - ! if tile crosses the edge of the snow albedo 10x10deg box, expand the - ! search area into the neighbouring 10x10deg box - hhtil_max=hhtil_min - vvtil_max=vvtil_min - if (floor(min_lon(n)/10) .ne. floor(max_lon(n)/10)) hhtil_max=hhtil_min+1 - if (floor(min_lat(n)/10) .ne. floor(max_lat(n)/10)) vvtil_max=vvtil_min+1 - - ! Safety checks: - ! 1. Make sure vv's and hh's are within the range. If min>max, swap them. - if (vvtil_min .gt. vvtil_max) then - dummy =vvtil_min - vvtil_min=vvtil_max - vvtil_max=dummy - endif - if (hhtil_min .gt. hhtil_max) then - dummy =hhtil_min - hhtil_min=hhtil_max - hhtil_max=dummy - endif - - ! 2. Keep within the range. - vvtil_min=max(vvtil_min,1) - vvtil_max=min(vvtil_max,18) - hhtil_min=max(hhtil_min,1) - hhtil_max=min(hhtil_max,36) - - do hhtil=hhtil_min,hhtil_max ! loop through input files - horizontal direction - do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction - - ! Find indices ranges corresponding to the current tile area. - imin=floor((min_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 - imax=floor((max_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 - jmin=floor((min_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 - jmax=floor((max_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 - ! Keep within the range. - imin=max(imin,1) - imax=min(imax,xdim) - jmin=max(jmin,1) - jmax=min(jmax,ydim) - - ! Generate sums and counts using current tile corresponding indices - sno_alb_sum= sno_alb_sum + & - sum(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax), & - stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & - stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).le.1.0) - - sno_alb_cnt= sno_alb_cnt + & - count(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).gt.0.0 .and. & - stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax).le.1.0) - - end do ! vvtil - end do ! hhtil - - ! Calculate snow albedo for the current tile - snw_alb(n) = sno_alb_sum / max(1.0,sno_alb_cnt) - if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=MAPL_UNDEF !1.E15 - - ! If no valid solution found, and if tile size smaller than snow albedo resolution, - ! expand search area by 1-tile padding. - - ! Size of a tile (in both directions) - pad_lon=(max_lon(n)-min_lon(n)) - pad_lat=(max_lat(n)-min_lat(n)) - - if (snw_alb(n) .le. 0.0 .and. (pad_lon .lt. alb_res .or. pad_lat .lt. alb_res)) then - - count_init_invalid=count_init_invalid+1 + + ! Set sums and counts to zero + sno_alb_sum=0. + sno_alb_cnt=0. + + ! Use tile's min/max lat/lon info to identify the 10x10deg input file(s) + ! indexes + vvtil_min=floor((min_lat(n)+ 90.0)/10.)+1 + hhtil_min=floor((min_lon(n)+180.0)/10.)+1 + + ! if tile crosses the edge of the snow albedo 10x10deg box, expand the + ! search area into the neighbouring 10x10deg box + hhtil_max=hhtil_min + vvtil_max=vvtil_min + if (floor(min_lon(n)/10) .ne. floor(max_lon(n)/10)) hhtil_max=hhtil_min+1 + if (floor(min_lat(n)/10) .ne. floor(max_lat(n)/10)) vvtil_max=vvtil_min+1 + + ! Safety check; keep within the range + vvtil_min=max(vvtil_min,1) + vvtil_max=min(vvtil_max,18) + hhtil_min=max(hhtil_min,1) + hhtil_max=min(hhtil_max,36) + + do hhtil=hhtil_min,hhtil_max ! loop through input files - horizontal direction + do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction - do hhtil=hhtil_min,hhtil_max ! loop through input files - horizontal direction - do vvtil=vvtil_min,vvtil_max ! loop through input files - vertical direction - - ! Repeat the steps for extracting snow albedo value - imin2=floor((min_lon(n)-pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0))+1 - imax2=floor((max_lon(n)+pad_lon+180.0 - (hhtil-1)*10.0) * (xdim/10.0))+1 - jmin2=floor((min_lat(n)-pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0))+1 - jmax2=floor((max_lat(n)+pad_lat+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0))+1 - imin2=max(imin2,1) - imax2=min(imax2,xdim) - jmin2=max(jmin2,1) - jmax2=min(jmax2,ydim) - - sno_alb_sum2= sno_alb_sum2 + & - sum(stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2), & - stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & - stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).le.1.0) - - sno_alb_cnt2= sno_alb_cnt2 + & - count(stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).gt.0.0 .and. & - stch_snw_alb(hhtil,vvtil,imin2:imax2,jmin2:jmax2).le.1.0) - - end do ! vvtil - end do ! hhtil + ! Find indices ranges corresponding to the current tile area. + imin=floor((min_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 + imax=floor((max_lon(n)+180.0 - (hhtil-1)*10.0) * (xdim/10.0)) +1 + jmin=floor((min_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 + jmax=floor((max_lat(n)+ 90.0 - (vvtil-1)*10.0) * (ydim/10.0)) +1 + + ! if no matching grids, go to the next vv/hh box + if (imin .gt. xdim .or. jmin .gt. ydim .or. imax .lt. 1 .or. jmax .lt. 1) cycle + + ! Keep within the range, to include only the portion of the tile within this vv/hh box + imin=max(imin,1) + imax=min(imax,xdim) + jmin=max(jmin,1) + jmax=min(jmax,ydim) - snw_alb(n) = sno_alb_sum2 / max(1.0,sno_alb_cnt2) - if (snw_alb(n) .le. 0.0 .or. snw_alb(n) .gt. 1.0 ) snw_alb(n)=MAPL_UNDEF !1.E15 + ! Generate sums and counts using current tile corresponding indices + sno_alb_sum = sno_alb_sum + sum(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax)) + sno_alb_cnt = sno_alb_cnt + (imax-imin+1)*(jmax-jmin+1) - endif - + end do ! vvtil + end do ! hhtil + + ! If matching grids found, calculate snow albedo for the current tile + if (sno_alb_sum .ne. 0.0 .and. sno_alb_cnt .ne. 0) snw_alb(n)=min(1.0,max(0.0,sno_alb_sum/sno_alb_cnt)) + end do ! n-loop over tiles ! write snow albedo into clsm/catch_params.nc4 @@ -3205,7 +3147,6 @@ SUBROUTINE MODIS_snow_alb ( ) endif print*, 'Ended tile loop for snow albedo. ' - print*, 'Initially found ', count_init_invalid, ' tiles with no-data values for snow albedo (out of ', maxcat,')' END SUBROUTINE MODIS_snow_alb From 3befabea8ef35f0584f3f00b3815c77df96d74bd Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Tue, 15 Nov 2022 14:49:56 -0500 Subject: [PATCH 60/77] additional minor clean-up of subroutine MODIS_snow_alb() --- .../Utils/Raster/mod_process_hres_data.F90 | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 index eba91c7f5..4909efa06 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/mod_process_hres_data.F90 @@ -2995,7 +2995,11 @@ END SUBROUTINE hres_gswp2 SUBROUTINE MODIS_snow_alb ( ) - ! Process static snow albedo calculated from MODIS climatology and write into clsm/catch_params.nc4 + ! Map static, MODIS climatology-based snow albedo from 30-arcsec raster + ! grid to tile space and write into clsm/catch_params.nc4. + ! + ! Assumes that input snow albedo on raster grid is backfilled + ! (i.e., does not contain no-data values). ! ! Biljana Orescanin July 2022, SSAI@NASA @@ -3003,7 +3007,7 @@ SUBROUTINE MODIS_snow_alb ( ) character*200 :: fname character*2 :: vv,hh - integer :: n,maxcat,ncid,status + integer :: n,N_tile,ncid,status real,allocatable,dimension(:) :: min_lon,max_lon,min_lat,max_lat,snw_alb integer(kind=4),parameter :: xdim = 1200, ydim = 1200 real,dimension(xdim,ydim) :: stch_snw_alb_tmp @@ -3015,23 +3019,23 @@ SUBROUTINE MODIS_snow_alb ( ) integer(kind=4) :: imin,imax,jmin,jmax,varid1 logical :: file_exists - ! Read number of catchment-tiles (maxcat) from catchment.def file + ! Read number of catchment-tiles (N_tile) from catchment.def file fname='clsm/catchment.def' open (10,file=fname,status='old',action='read',form='formatted') - read(10,*) maxcat + read(10,*) N_tile ! Read min/max lat/lons to use when locating snow albedo grids in ! the stitched MODIS albedo file - allocate (min_lon(1:maxcat)) - allocate (min_lat(1:maxcat)) - allocate (max_lon(1:maxcat)) - allocate (max_lat(1:maxcat)) - allocate (snw_alb(1:maxcat)) + allocate (min_lon(1:N_tile)) + allocate (min_lat(1:N_tile)) + allocate (max_lon(1:N_tile)) + allocate (max_lat(1:N_tile)) + allocate (snw_alb(1:N_tile)) ! Start by setting all snow albedo values to missing snw_alb(:)=MAPL_UNDEF - do n = 1, maxcat + do n = 1, N_tile read (10,*) tindex1,pfaf1,minlon,maxlon,minlat,maxlat min_lon(n) = minlon max_lon(n) = maxlon @@ -3041,7 +3045,7 @@ SUBROUTINE MODIS_snow_alb ( ) close (10,status='keep') - !------------ Get the information on snow albedo ----- + ! ----------- Get the information on snow albedo ----- ! ----------- The information on snow albedo is stored in 10x10deg 30-arcsec resolution files. ! ----------- Read in this information, then loop over the tiles to find a corresponding snow albedo. @@ -3057,9 +3061,6 @@ SUBROUTINE MODIS_snow_alb ( ) ! sheets and is weighted by the grid-cell area). fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v2/snow_alb_FillVal_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' - ! MODIS-based climatology albedo raster files (NoData set to 1e+15) - !fname = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/land/albedo/snow/MODIS/v1/snow_alb_noFill_MOD10A1.061_30arcsec_H'//hh//'V'//vv//'.nc' - ! Open the file. (NF90_NOWRITE ensures read-only access to the file) status=NF_OPEN(trim(fname),NF_NOWRITE, ncid) ; VERIFY_(STATUS) ! Based on vars name, get the varids. @@ -3083,7 +3084,7 @@ SUBROUTINE MODIS_snow_alb ( ) ! loop over tiles print*, 'Starting tile loop for snow albedo.' - do n = 1, maxcat ! loop over tiles + do n = 1, N_tile ! loop over tiles ! Set sums and counts to zero sno_alb_sum=0. @@ -3126,14 +3127,15 @@ SUBROUTINE MODIS_snow_alb ( ) jmax=min(jmax,ydim) ! Generate sums and counts using current tile corresponding indices - sno_alb_sum = sno_alb_sum + sum(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax)) + sno_alb_sum = sno_alb_sum + sum(stch_snw_alb(hhtil,vvtil,imin:imax,jmin:jmax)) sno_alb_cnt = sno_alb_cnt + (imax-imin+1)*(jmax-jmin+1) end do ! vvtil end do ! hhtil - ! If matching grids found, calculate snow albedo for the current tile - if (sno_alb_sum .ne. 0.0 .and. sno_alb_cnt .ne. 0) snw_alb(n)=min(1.0,max(0.0,sno_alb_sum/sno_alb_cnt)) + ! If matching grids found, calculate snow albedo for the current tile; + ! ensure that resulting value is within physical range [0,1]. + if (sno_alb_cnt .ne. 0) snw_alb(n)=min(1.0,max(0.0,sno_alb_sum/sno_alb_cnt)) end do ! n-loop over tiles @@ -3142,7 +3144,7 @@ SUBROUTINE MODIS_snow_alb ( ) if(file_exists) then status = NF_OPEN ('clsm/catch_params.nc4', NF_WRITE, ncid ) ; VERIFY_(STATUS) - status = NF_PUT_VARA_REAL(NCID,NC_VarID(NCID,'SNOWALB'),(/1/),(/maxcat/),real(snw_alb)) ; VERIFY_(STATUS) + status = NF_PUT_VARA_REAL(NCID,NC_VarID(NCID,'SNOWALB'),(/1/),(/N_tile/),real(snw_alb)) ; VERIFY_(STATUS) STATUS = NF_CLOSE (NCID) ; VERIFY_(STATUS) endif From 3b15cac801fdaadebbacc25cf33bc0399025ed0a Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Tue, 15 Nov 2022 15:41:59 -0500 Subject: [PATCH 61/77] added "only" specs to "use" statements in CatchmentRst.F90 and CatchmentCNRst.F90 --- .../GEOSsurface_GridComp/Utils/mk_restarts/CatchmentCNRst.F90 | 3 ++- .../GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentCNRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentCNRst.F90 index ecab0906e..d28137c71 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentCNRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentCNRst.F90 @@ -1,7 +1,8 @@ #include "MAPL_Generic.h" module CatchmentCNRstMod - use mk_restarts_getidsMod + use mk_restarts_getidsMod, ONLY: & + GetIds use mpi use MAPL use CatchmentRstMod, only : CatchmentRst diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index 34406b852..f0ac9b971 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -1,7 +1,9 @@ #include "MAPL_Generic.h" module CatchmentRstMod - use mk_restarts_getidsMod + use mk_restarts_getidsMod, ONLY: & + GetIds, & + ReadTileFile_RealLatLon use MAPL use MAPL_Base, ONLY: MAPL_UNDEF use mpi From c9df40ae8216ada26a125387ca6dac13571c6a61 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Wed, 16 Nov 2022 09:48:31 -0500 Subject: [PATCH 62/77] add snowalb to mk_CatchmetRestart so regrid.pl can work --- .../Utils/mk_restarts/mk_CatchRestarts.F90 | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 index 4e6b2d94f..14e15320b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 @@ -267,7 +267,8 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) real, allocatable :: ARW1(:), ARW2(:), ARW3(:), ARW4(:) real, allocatable :: TSA1(:), TSA2(:), TSB1(:), TSB2(:) real, allocatable :: ATAU2(:), BTAU2(:), DP2BR(:), rity(:) - + real, allocatable :: snowalb(:) + real :: zdep1, zdep2, zdep3, zmet, term1, term2, rdum real, allocatable :: var1(:),var2(:,:) character*256 :: vname @@ -280,9 +281,10 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) integer, pointer :: Ido(:), idx(:), id(:) logical :: InIsOld type(NetCDF4_Fileformatter) :: InFmt,OutFmt,CatchFmt - type(FileMetadata) :: InCfg,OutCfg + type(FileMetadata) :: InCfg,OutCfg, meta_ type(StringVariableMap), pointer :: variables type(Variable), pointer :: myVariable + type(Variable) :: var type(StringVariableMapIterator) :: var_iter character(len=:), pointer :: var_name,dname type(StringVector), pointer :: var_dimensions @@ -303,15 +305,6 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call InFmt%open(InRestart,pFIO_READ,__RC__) InCfg=InFmt%read(__RC__) - call MAPL_IOChangeRes(InCfg,OutCfg,(/'tile'/),(/ntiles/),__RC__) - i = index(InRestart,'/',back=.true.) - OutFileName = "OutData/"//trim(InRestart(i+1:)) - call OutFmt%create(OutFileName,__RC__) - call OutFmt%write(OutCfg,__RC__) - call MAPL_IOCountNonDimVars(OutCfg,nvars,__RC__) - - allocate(written(nvars)) - written=.false. else @@ -411,6 +404,13 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call MAPL_VarRead ( catchFmt ,'WPWET', WPWET, __RC__) call MAPL_VarRead ( catchFmt ,'DP2BR', DP2BR, __RC__) call MAPL_VarRead ( catchFmt ,'POROS', POROS, __RC__) + + meta_ = CatchFmt%read(__RC__) + if (meta_%has_variable('SNOWALB')) then + allocate(snowalb(ntiles)) + call MAPL_VarRead ( CatchFmt ,'SNOWALB', snowalb, __RC__) + endif + call catchFmt%close(__RC__) else @@ -571,6 +571,23 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) endif HAVE if (filetype == 0) then + + call MAPL_IOChangeRes(InCfg,OutCfg,(/'tile'/),(/ntiles/),__RC__) + i = index(InRestart,'/',back=.true.) + OutFileName = "OutData/"//trim(InRestart(i+1:)) + call OutFmt%create(OutFileName,__RC__) + + if (allocated(snowalb)) then + var = Variable(type=pFIO_REAL32, dimensions='tile') + call var%add_attribute('long_name', 'snow_albedo') + call var%add_attribute('units', '1') + call OutCFG%add_variable('SNOWALB', var) + endif + + call OutFmt%write(OutCfg,__RC__) + + + call MAPL_VarWrite(OutFmt,names(1),BF1(Idx)) call MAPL_VarWrite(OutFmt,names(2),BF2(Idx)) call MAPL_VarWrite(OutFmt,names(3),BF3(Idx)) @@ -602,8 +619,13 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call MAPL_VarWrite(OutFmt,names(29),BTAU2(Idx)) call MAPL_VarWrite(OutFmt,'OLD_ITY',rity(Idx)) + if (allocated(snowalb)) then + call MAPL_VarWrite(OutFmt,'SNOWALB',snowalb(Idx)) + endif call MAPL_IOCountNonDimVars(InCfg,nvars) + allocate(written(nvars)) + written=.false. variables => InCfg%get_variables() var_iter = variables%begin() @@ -616,6 +638,7 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) if ( trim(var_name) == trim(names(j)) ) written(i) = .true. enddo if (trim(var_name) == "OLD_ITY" ) written(i) = .true. + if (trim(var_name) == "SNOWALB" ) written(i) = .true. call var_iter%next() From 5aea1621481c430ed3b7a1f5a06020deaf06b0c0 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Wed, 16 Nov 2022 15:40:34 -0500 Subject: [PATCH 63/77] no re-tile for bcs parameters in catchment restart file --- .../Utils/mk_restarts/CatchmentRst.F90 | 208 +++--------------- 1 file changed, 35 insertions(+), 173 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index f0ac9b971..8e2d04b47 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -266,40 +266,14 @@ subroutine read_shared_nc4(this, formatter, rc) integer, optional, intent(out):: rc integer :: status - call MAPL_VarRead(formatter,"BF1",this%bf1, __RC__) - call MAPL_VarRead(formatter,"BF2",this%bf2, __RC__) - call MAPL_VarRead(formatter,"BF3",this%bf3, __RC__) + ! the four variables are used as scaler call MAPL_VarRead(formatter,"VGWMAX",this%vgwmax, __RC__) call MAPL_VarRead(formatter,"CDCR1",this%cdcr1, __RC__) call MAPL_VarRead(formatter,"CDCR2",this%cdcr2, __RC__) - call MAPL_VarRead(formatter,"PSIS",this%psis, __RC__) - call MAPL_VarRead(formatter,"BEE",this%bee, __RC__) call MAPL_VarRead(formatter,"POROS",this%poros, __RC__) - call MAPL_VarRead(formatter,"WPWET",this%wpwet, __RC__) - call MAPL_VarRead(formatter,"COND",this%cond, __RC__) - call MAPL_VarRead(formatter,"GNU",this%gnu, __RC__) - call MAPL_VarRead(formatter,"ARS1",this%ars1, __RC__) - call MAPL_VarRead(formatter,"ARS2",this%ars2, __RC__) - call MAPL_VarRead(formatter,"ARS3",this%ars3, __RC__) - call MAPL_VarRead(formatter,"ARA1",this%ara1, __RC__) - call MAPL_VarRead(formatter,"ARA2",this%ara2, __RC__) - call MAPL_VarRead(formatter,"ARA3",this%ara3, __RC__) - call MAPL_VarRead(formatter,"ARA4",this%ara4, __RC__) - call MAPL_VarRead(formatter,"ARW1",this%arw1, __RC__) - call MAPL_VarRead(formatter,"ARW2",this%arw2, __RC__) - call MAPL_VarRead(formatter,"ARW3",this%arw3, __RC__) - call MAPL_VarRead(formatter,"ARW4",this%arw4, __RC__) - call MAPL_VarRead(formatter,"TSA1",this%tsa1, __RC__) - call MAPL_VarRead(formatter,"TSA2",this%tsa2, __RC__) - call MAPL_VarRead(formatter,"TSB1",this%tsb1, __RC__) - call MAPL_VarRead(formatter,"TSB2",this%tsb2, __RC__) - call MAPL_VarRead(formatter,"ATAU",this%atau, __RC__) - call MAPL_VarRead(formatter,"BTAU",this%btau, __RC__) + call MAPL_VarRead(formatter,"TC",this%tc, __RC__) call MAPL_VarRead(formatter,"QC",this%qc, __RC__) -! -! call MAPL_VarRead(formatter,"OLD_ITY",this%ity, __RC__) -! call MAPL_VarRead(formatter,"CAPAC",this%capac, __RC__) call MAPL_VarRead(formatter,"CATDEF",this%catdef, __RC__) call MAPL_VarRead(formatter,"RZEXC",this%rzexc, __RC__) @@ -445,36 +419,11 @@ subroutine allocate_catch(this,rc) integer, optional, intent(out):: rc integer :: ntiles ntiles = this%ntiles - allocate( this% bf1(ntiles) ) - allocate( this% bf2(ntiles) ) - allocate( this% bf3(ntiles) ) allocate( this% vgwmax(ntiles) ) allocate( this% cdcr1(ntiles) ) allocate( this% cdcr2(ntiles) ) - allocate( this% psis(ntiles) ) - allocate( this% bee(ntiles) ) allocate( this% poros(ntiles) ) - allocate( this% wpwet(ntiles) ) - allocate( this% cond(ntiles) ) - allocate( this% gnu(ntiles) ) - allocate( this% ars1(ntiles) ) - allocate( this% ars2(ntiles) ) - allocate( this% ars3(ntiles) ) - allocate( this% ara1(ntiles) ) - allocate( this% ara2(ntiles) ) - allocate( this% ara3(ntiles) ) - allocate( this% ara4(ntiles) ) - allocate( this% arw1(ntiles) ) - allocate( this% arw2(ntiles) ) - allocate( this% arw3(ntiles) ) - allocate( this% arw4(ntiles) ) - allocate( this% tsa1(ntiles) ) - allocate( this% tsa2(ntiles) ) - allocate( this% tsb1(ntiles) ) - allocate( this% tsb2(ntiles) ) - allocate( this% atau(ntiles) ) - allocate( this% btau(ntiles) ) - allocate( this% ity(ntiles) ) + allocate( this% tc(ntiles,4) ) allocate( this% qc(ntiles,4) ) allocate( this% capac(ntiles) ) @@ -491,9 +440,6 @@ subroutine allocate_catch(this,rc) if (this%meta%has_variable('TSURF')) then allocate( this% tsurf(ntiles) ) endif - if (this%meta%has_variable('SNOWALB')) then - allocate( this% snowalb(ntiles) ) - endif allocate( this% wesnn1(ntiles) ) allocate( this% wesnn2(ntiles) ) @@ -553,38 +499,35 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) inquire(file = trim(DataDir)//'/clsm/catch_params.nc4', exist=file_exists) inquire(file = trim(DataDir)//"/clsm/CLM_veg_typs_fracs",exist=NewLand ) - if (size(this%ara1) /= this%ntiles ) then - ! it is just re-allocate - this%ity = DP2BR - this%ARA1 = DP2BR - this%ARA2 = DP2BR - this%ARA3 = DP2BR - this%ARA4 = DP2BR - this%ARS1 = DP2BR - this%ARS2 = DP2BR - this%ARS3 = DP2BR - this%ARW1 = DP2BR - this%ARW2 = DP2BR - this%ARW3 = DP2BR - this%ARW4 = DP2BR - this%ATAU = DP2BR - this%BTAU = DP2BR - this%PSIS = DP2BR - this%BEE = DP2BR - this%BF1 = DP2BR - this%BF2 = DP2BR - this%BF3 = DP2BR - this%TSA1 = DP2BR - this%TSA2 = DP2BR - this%TSB1 = DP2BR - this%TSB2 = DP2BR - this%COND = DP2BR - this%WPWET = DP2BR - this%POROS = DP2BR - this%VGWMAX = DP2BR - this%cdcr1 = DP2BR - this%cdcr2 = DP2BR - endif + this%ity = DP2BR + this%ARA1 = DP2BR + this%ARA2 = DP2BR + this%ARA3 = DP2BR + this%ARA4 = DP2BR + this%ARS1 = DP2BR + this%ARS2 = DP2BR + this%ARS3 = DP2BR + this%ARW1 = DP2BR + this%ARW2 = DP2BR + this%ARW3 = DP2BR + this%ARW4 = DP2BR + this%ATAU = DP2BR + this%BTAU = DP2BR + this%PSIS = DP2BR + this%BEE = DP2BR + this%BF1 = DP2BR + this%BF2 = DP2BR + this%BF3 = DP2BR + this%TSA1 = DP2BR + this%TSA2 = DP2BR + this%TSB1 = DP2BR + this%TSB2 = DP2BR + this%COND = DP2BR + this%WPWET = DP2BR + this%POROS = DP2BR + this%VGWMAX = DP2BR + this%cdcr1 = DP2BR + this%cdcr2 = DP2BR if(file_exists) then call CatchFmt%Open(trim(DataDir)//'/clsm/catch_params.nc4', pFIO_READ, __RC__) @@ -935,92 +878,15 @@ subroutine re_tile(this, InTileFile, OutBcsDir, OutTileFile, surflay, rc) var_out = this%poros(id_glb(:)) this%poros = var_out - var_out = this%cond(id_glb(:)) - this%cond = var_out - - var_out = this%psis(id_glb(:)) - this%psis = var_out - - var_out = this%bee(id_glb(:)) - this%bee = var_out - - var_out = this%wpwet(id_glb(:)) - this%wpwet = var_out - - var_out = this%gnu(id_glb(:)) - this%gnu = var_out - var_out = this%vgwmax(id_glb(:)) this%vgwmax = var_out - var_out = this%bf1(id_glb(:)) - this%bf1 = var_out - - var_out = this%bf2(id_glb(:)) - this%bf2 = var_out - - var_out = this%bf3(id_glb(:)) - this%bf3 = var_out - var_out = this%cdcr1(id_glb(:)) this%cdcr1 = var_out var_out = this%cdcr2(id_glb(:)) this%cdcr2 = var_out - var_out = this%ars1(id_glb(:)) - this%ars1 = var_out - - var_out = this%ars2(id_glb(:)) - this%ars2 = var_out - - var_out = this%ars3(id_glb(:)) - this%ars3 = var_out - - var_out = this%ara1(id_glb(:)) - this%ara1 = var_out - - var_out = this%ara2(id_glb(:)) - this%ara2 = var_out - - var_out = this%ara3(id_glb(:)) - this%ara3 = var_out - - var_out = this%ara4(id_glb(:)) - this%ara4 = var_out - - var_out = this%arw1(id_glb(:)) - this%arw1 = var_out - - var_out = this%arw2(id_glb(:)) - this%arw2 = var_out - - var_out = this%arw3(id_glb(:)) - this%arw3 = var_out - - var_out = this%arw4(id_glb(:)) - this%arw4 = var_out - - var_out = this%tsa1(id_glb(:)) - this%tsa1 = var_out - - var_out = this%tsa2(id_glb(:)) - this%tsa2 = var_out - - var_out = this%tsb1(id_glb(:)) - this%tsb1 = var_out - - var_out = this%tsb2(id_glb(:)) - this%tsb2 = var_out - - var_out = this%atau(id_glb(:)) - this%atau = var_out - - var_out = this%btau(id_glb(:)) - this%btau = var_out - - this%ity = [(k*1., k=1, out_ntiles)] - tmp2d = this%tc deallocate(this%tc) allocate(this%tc(out_ntiles, 4)) @@ -1098,11 +964,6 @@ subroutine re_tile(this, InTileFile, OutBcsDir, OutTileFile, surflay, rc) this%tsurf = var_out endif - if (this%meta%has_variable('SNOWALB')) then - var_out = this%snowalb(id_glb(:)) - this%snowalb = var_out - endif - ! CH CM CQ FR WW ! WW if(allocated(tmp2d)) deallocate(tmp2d) @@ -1298,12 +1159,13 @@ end subroutine re_scale subroutine set_scale_var(this ) class(CatchmentRst), intent(inout) :: this - this%old_catdef = this%catdef this%old_poros = this%poros this%old_cdcr1 = this%cdcr1 this%old_cdcr2 = this%cdcr2 - this%old_rzexc = this%rzexc this%old_vgwmax = this%vgwmax + + this%old_catdef = this%catdef + this%old_rzexc = this%rzexc this%old_sndzn3 = this%sndzn3 this%old_ghtcnt1 = this%ghtcnt1 this%old_ghtcnt2 = this%ghtcnt2 From 8020e32b0cabee822085555a6e50c2eb95f00c19 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 17 Nov 2022 08:51:35 -0500 Subject: [PATCH 64/77] add snowalb to restart when using regrid.pl --- .../Utils/mk_restarts/mk_CatchRestarts.F90 | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 index 4e6b2d94f..14e15320b 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 @@ -267,7 +267,8 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) real, allocatable :: ARW1(:), ARW2(:), ARW3(:), ARW4(:) real, allocatable :: TSA1(:), TSA2(:), TSB1(:), TSB2(:) real, allocatable :: ATAU2(:), BTAU2(:), DP2BR(:), rity(:) - + real, allocatable :: snowalb(:) + real :: zdep1, zdep2, zdep3, zmet, term1, term2, rdum real, allocatable :: var1(:),var2(:,:) character*256 :: vname @@ -280,9 +281,10 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) integer, pointer :: Ido(:), idx(:), id(:) logical :: InIsOld type(NetCDF4_Fileformatter) :: InFmt,OutFmt,CatchFmt - type(FileMetadata) :: InCfg,OutCfg + type(FileMetadata) :: InCfg,OutCfg, meta_ type(StringVariableMap), pointer :: variables type(Variable), pointer :: myVariable + type(Variable) :: var type(StringVariableMapIterator) :: var_iter character(len=:), pointer :: var_name,dname type(StringVector), pointer :: var_dimensions @@ -303,15 +305,6 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call InFmt%open(InRestart,pFIO_READ,__RC__) InCfg=InFmt%read(__RC__) - call MAPL_IOChangeRes(InCfg,OutCfg,(/'tile'/),(/ntiles/),__RC__) - i = index(InRestart,'/',back=.true.) - OutFileName = "OutData/"//trim(InRestart(i+1:)) - call OutFmt%create(OutFileName,__RC__) - call OutFmt%write(OutCfg,__RC__) - call MAPL_IOCountNonDimVars(OutCfg,nvars,__RC__) - - allocate(written(nvars)) - written=.false. else @@ -411,6 +404,13 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call MAPL_VarRead ( catchFmt ,'WPWET', WPWET, __RC__) call MAPL_VarRead ( catchFmt ,'DP2BR', DP2BR, __RC__) call MAPL_VarRead ( catchFmt ,'POROS', POROS, __RC__) + + meta_ = CatchFmt%read(__RC__) + if (meta_%has_variable('SNOWALB')) then + allocate(snowalb(ntiles)) + call MAPL_VarRead ( CatchFmt ,'SNOWALB', snowalb, __RC__) + endif + call catchFmt%close(__RC__) else @@ -571,6 +571,23 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) endif HAVE if (filetype == 0) then + + call MAPL_IOChangeRes(InCfg,OutCfg,(/'tile'/),(/ntiles/),__RC__) + i = index(InRestart,'/',back=.true.) + OutFileName = "OutData/"//trim(InRestart(i+1:)) + call OutFmt%create(OutFileName,__RC__) + + if (allocated(snowalb)) then + var = Variable(type=pFIO_REAL32, dimensions='tile') + call var%add_attribute('long_name', 'snow_albedo') + call var%add_attribute('units', '1') + call OutCFG%add_variable('SNOWALB', var) + endif + + call OutFmt%write(OutCfg,__RC__) + + + call MAPL_VarWrite(OutFmt,names(1),BF1(Idx)) call MAPL_VarWrite(OutFmt,names(2),BF2(Idx)) call MAPL_VarWrite(OutFmt,names(3),BF3(Idx)) @@ -602,8 +619,13 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call MAPL_VarWrite(OutFmt,names(29),BTAU2(Idx)) call MAPL_VarWrite(OutFmt,'OLD_ITY',rity(Idx)) + if (allocated(snowalb)) then + call MAPL_VarWrite(OutFmt,'SNOWALB',snowalb(Idx)) + endif call MAPL_IOCountNonDimVars(InCfg,nvars) + allocate(written(nvars)) + written=.false. variables => InCfg%get_variables() var_iter = variables%begin() @@ -616,6 +638,7 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) if ( trim(var_name) == trim(names(j)) ) written(i) = .true. enddo if (trim(var_name) == "OLD_ITY" ) written(i) = .true. + if (trim(var_name) == "SNOWALB" ) written(i) = .true. call var_iter%next() From bceedb3b4285624eceb3d7593523f34fde139677 Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Thu, 17 Nov 2022 14:02:29 -0500 Subject: [PATCH 65/77] minor clarification in comments (CatchmentRst.F90) --- .../GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index 8e2d04b47..ae80ddd03 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -266,12 +266,13 @@ subroutine read_shared_nc4(this, formatter, rc) integer, optional, intent(out):: rc integer :: status - ! the four variables are used as scaler + ! these four (time-invariant) variables are used for rescaling of prognostic variables call MAPL_VarRead(formatter,"VGWMAX",this%vgwmax, __RC__) call MAPL_VarRead(formatter,"CDCR1",this%cdcr1, __RC__) call MAPL_VarRead(formatter,"CDCR2",this%cdcr2, __RC__) call MAPL_VarRead(formatter,"POROS",this%poros, __RC__) + ! Catchment model prognostic variables (and some diagnostics needed in Catch restart for GCM) call MAPL_VarRead(formatter,"TC",this%tc, __RC__) call MAPL_VarRead(formatter,"QC",this%qc, __RC__) call MAPL_VarRead(formatter,"CAPAC",this%capac, __RC__) @@ -1146,7 +1147,7 @@ subroutine re_scale(this, surflay, wemin_in, wemin_out, rc) endif - ! PEATCLSM - ensure low CATDEF on peat tiles where "old" restart is not also peat + ! PEATCLSM - ensure low CATDEF on peat tiles where "old" restart is not also peat ! ------------------------------------------------------------------------------- where ( (this%old_poros < PEATCLSM_POROS_THRESHOLD) .and. (this%poros >= PEATCLSM_POROS_THRESHOLD) ) From 91ac79a1f1f138bf3428f619ae787cb62f6f68f8 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 18 Nov 2022 10:10:23 -0500 Subject: [PATCH 66/77] remove snowalb when target bc does not have --- .../Utils/mk_restarts/CatchmentRst.F90 | 3 ++- .../Utils/mk_restarts/mk_CatchRestarts.F90 | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index ae80ddd03..fdf99f642 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -581,8 +581,9 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) call var%add_attribute('units', '1') call this%meta%add_variable('SNOWALB', var) endif + elseif (this%meta%has_variable('SNOWALB')) then + call this%meta%remove_variable('SNOWALB') endif - call CatchFmt%close() else open(unit=21, file=trim(DataDir)//'/clsm/mosaic_veg_typs_fracs',form='formatted') diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 index 14e15320b..60cac1687 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 @@ -578,10 +578,12 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call OutFmt%create(OutFileName,__RC__) if (allocated(snowalb)) then - var = Variable(type=pFIO_REAL32, dimensions='tile') - call var%add_attribute('long_name', 'snow_albedo') - call var%add_attribute('units', '1') - call OutCFG%add_variable('SNOWALB', var) + if (.not. OutCFG%has_varibale('SNOWALB') then + var = Variable(type=pFIO_REAL32, dimensions='tile') + call var%add_attribute('long_name', 'snow_albedo') + call var%add_attribute('units', '1') + call OutCFG%add_variable('SNOWALB', var) + endif endif call OutFmt%write(OutCfg,__RC__) From d718c1f97b140016ab827811dcc182c0f948523d Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 18 Nov 2022 10:57:33 -0500 Subject: [PATCH 67/77] correct typo --- .../GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 index 60cac1687..9fe3f0815 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 @@ -578,7 +578,7 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call OutFmt%create(OutFileName,__RC__) if (allocated(snowalb)) then - if (.not. OutCFG%has_varibale('SNOWALB') then + if (.not. OutCFG%has_varibale('SNOWALB')) then var = Variable(type=pFIO_REAL32, dimensions='tile') call var%add_attribute('long_name', 'snow_albedo') call var%add_attribute('units', '1') From f0efe1ee6bcda7e19495939d6478eb25c19a14ef Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 18 Nov 2022 11:35:48 -0500 Subject: [PATCH 68/77] fix typo again --- .../GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 index 9fe3f0815..1c0df8c92 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 @@ -578,7 +578,7 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call OutFmt%create(OutFileName,__RC__) if (allocated(snowalb)) then - if (.not. OutCFG%has_varibale('SNOWALB')) then + if (.not. OutCFG%has_variable('SNOWALB')) then var = Variable(type=pFIO_REAL32, dimensions='tile') call var%add_attribute('long_name', 'snow_albedo') call var%add_attribute('units', '1') From e375bdfc9d08688180e731f4997a390d9b63d4a7 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 18 Nov 2022 15:12:43 -0500 Subject: [PATCH 69/77] allocate GNU . bug fix --- .../GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index fdf99f642..36b994176 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -523,6 +523,7 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) this%TSA2 = DP2BR this%TSB1 = DP2BR this%TSB2 = DP2BR + this%GNU = DP2BR this%COND = DP2BR this%WPWET = DP2BR this%POROS = DP2BR From 2fe381e04cd6d647d324939be6c4955f26b4f2c2 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Mon, 21 Nov 2022 10:11:49 -0500 Subject: [PATCH 70/77] remove snowalb when there is not catch_params.nc4 --- .../GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 index 36b994176..477e17d08 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/CatchmentRst.F90 @@ -624,6 +624,9 @@ subroutine add_bcs_to_rst(this, surflay, DataDir, rc) CLOSE (24, STATUS = 'KEEP') CLOSE (25, STATUS = 'KEEP') CLOSE (26, STATUS = 'KEEP') + + if (this%meta%has_variable('SNOWALB')) call this%meta%remove_variable('SNOWALB') + endif do n=1,ntiles From 84a3caff3edb0281e4d96907e20be1f711abb2da Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Tue, 22 Nov 2022 11:10:31 -0500 Subject: [PATCH 71/77] restore mk_CatchRestarts so regrid.pl would not work with new bcs with snowalb --- .../Utils/mk_restarts/mk_CatchRestarts.F90 | 45 +++++-------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 index 14e15320b..4e6b2d94f 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 @@ -267,8 +267,7 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) real, allocatable :: ARW1(:), ARW2(:), ARW3(:), ARW4(:) real, allocatable :: TSA1(:), TSA2(:), TSB1(:), TSB2(:) real, allocatable :: ATAU2(:), BTAU2(:), DP2BR(:), rity(:) - real, allocatable :: snowalb(:) - + real :: zdep1, zdep2, zdep3, zmet, term1, term2, rdum real, allocatable :: var1(:),var2(:,:) character*256 :: vname @@ -281,10 +280,9 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) integer, pointer :: Ido(:), idx(:), id(:) logical :: InIsOld type(NetCDF4_Fileformatter) :: InFmt,OutFmt,CatchFmt - type(FileMetadata) :: InCfg,OutCfg, meta_ + type(FileMetadata) :: InCfg,OutCfg type(StringVariableMap), pointer :: variables type(Variable), pointer :: myVariable - type(Variable) :: var type(StringVariableMapIterator) :: var_iter character(len=:), pointer :: var_name,dname type(StringVector), pointer :: var_dimensions @@ -305,6 +303,15 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call InFmt%open(InRestart,pFIO_READ,__RC__) InCfg=InFmt%read(__RC__) + call MAPL_IOChangeRes(InCfg,OutCfg,(/'tile'/),(/ntiles/),__RC__) + i = index(InRestart,'/',back=.true.) + OutFileName = "OutData/"//trim(InRestart(i+1:)) + call OutFmt%create(OutFileName,__RC__) + call OutFmt%write(OutCfg,__RC__) + call MAPL_IOCountNonDimVars(OutCfg,nvars,__RC__) + + allocate(written(nvars)) + written=.false. else @@ -404,13 +411,6 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call MAPL_VarRead ( catchFmt ,'WPWET', WPWET, __RC__) call MAPL_VarRead ( catchFmt ,'DP2BR', DP2BR, __RC__) call MAPL_VarRead ( catchFmt ,'POROS', POROS, __RC__) - - meta_ = CatchFmt%read(__RC__) - if (meta_%has_variable('SNOWALB')) then - allocate(snowalb(ntiles)) - call MAPL_VarRead ( CatchFmt ,'SNOWALB', snowalb, __RC__) - endif - call catchFmt%close(__RC__) else @@ -571,23 +571,6 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) endif HAVE if (filetype == 0) then - - call MAPL_IOChangeRes(InCfg,OutCfg,(/'tile'/),(/ntiles/),__RC__) - i = index(InRestart,'/',back=.true.) - OutFileName = "OutData/"//trim(InRestart(i+1:)) - call OutFmt%create(OutFileName,__RC__) - - if (allocated(snowalb)) then - var = Variable(type=pFIO_REAL32, dimensions='tile') - call var%add_attribute('long_name', 'snow_albedo') - call var%add_attribute('units', '1') - call OutCFG%add_variable('SNOWALB', var) - endif - - call OutFmt%write(OutCfg,__RC__) - - - call MAPL_VarWrite(OutFmt,names(1),BF1(Idx)) call MAPL_VarWrite(OutFmt,names(2),BF2(Idx)) call MAPL_VarWrite(OutFmt,names(3),BF3(Idx)) @@ -619,13 +602,8 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call MAPL_VarWrite(OutFmt,names(29),BTAU2(Idx)) call MAPL_VarWrite(OutFmt,'OLD_ITY',rity(Idx)) - if (allocated(snowalb)) then - call MAPL_VarWrite(OutFmt,'SNOWALB',snowalb(Idx)) - endif call MAPL_IOCountNonDimVars(InCfg,nvars) - allocate(written(nvars)) - written=.false. variables => InCfg%get_variables() var_iter = variables%begin() @@ -638,7 +616,6 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) if ( trim(var_name) == trim(names(j)) ) written(i) = .true. enddo if (trim(var_name) == "OLD_ITY" ) written(i) = .true. - if (trim(var_name) == "SNOWALB" ) written(i) = .true. call var_iter%next() From 371e5577987310d136fc105192f7d757f9966eec Mon Sep 17 00:00:00 2001 From: Rolf Reichle Date: Tue, 29 Nov 2022 16:29:09 -0500 Subject: [PATCH 72/77] restoring mk_CatchRestarts.F90 from "develop" --- .../Utils/mk_restarts/mk_CatchRestarts.F90 | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 index ea11c3588..4e6b2d94f 100644 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/mk_restarts/mk_CatchRestarts.F90 @@ -267,8 +267,7 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) real, allocatable :: ARW1(:), ARW2(:), ARW3(:), ARW4(:) real, allocatable :: TSA1(:), TSA2(:), TSB1(:), TSB2(:) real, allocatable :: ATAU2(:), BTAU2(:), DP2BR(:), rity(:) - real, allocatable :: snowalb(:) - + real :: zdep1, zdep2, zdep3, zmet, term1, term2, rdum real, allocatable :: var1(:),var2(:,:) character*256 :: vname @@ -281,10 +280,9 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) integer, pointer :: Ido(:), idx(:), id(:) logical :: InIsOld type(NetCDF4_Fileformatter) :: InFmt,OutFmt,CatchFmt - type(FileMetadata) :: InCfg,OutCfg, meta_ + type(FileMetadata) :: InCfg,OutCfg type(StringVariableMap), pointer :: variables type(Variable), pointer :: myVariable - type(Variable) :: var type(StringVariableMapIterator) :: var_iter character(len=:), pointer :: var_name,dname type(StringVector), pointer :: var_dimensions @@ -305,6 +303,15 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call InFmt%open(InRestart,pFIO_READ,__RC__) InCfg=InFmt%read(__RC__) + call MAPL_IOChangeRes(InCfg,OutCfg,(/'tile'/),(/ntiles/),__RC__) + i = index(InRestart,'/',back=.true.) + OutFileName = "OutData/"//trim(InRestart(i+1:)) + call OutFmt%create(OutFileName,__RC__) + call OutFmt%write(OutCfg,__RC__) + call MAPL_IOCountNonDimVars(OutCfg,nvars,__RC__) + + allocate(written(nvars)) + written=.false. else @@ -404,13 +411,6 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call MAPL_VarRead ( catchFmt ,'WPWET', WPWET, __RC__) call MAPL_VarRead ( catchFmt ,'DP2BR', DP2BR, __RC__) call MAPL_VarRead ( catchFmt ,'POROS', POROS, __RC__) - - meta_ = CatchFmt%read(__RC__) - if (meta_%has_variable('SNOWALB')) then - allocate(snowalb(ntiles)) - call MAPL_VarRead ( CatchFmt ,'SNOWALB', snowalb, __RC__) - endif - call catchFmt%close(__RC__) else @@ -571,7 +571,6 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) endif HAVE if (filetype == 0) then - call MAPL_VarWrite(OutFmt,names(1),BF1(Idx)) call MAPL_VarWrite(OutFmt,names(2),BF2(Idx)) call MAPL_VarWrite(OutFmt,names(3),BF3(Idx)) @@ -603,13 +602,8 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) call MAPL_VarWrite(OutFmt,names(29),BTAU2(Idx)) call MAPL_VarWrite(OutFmt,'OLD_ITY',rity(Idx)) - if (allocated(snowalb)) then - call MAPL_VarWrite(OutFmt,'SNOWALB',snowalb(Idx)) - endif call MAPL_IOCountNonDimVars(InCfg,nvars) - allocate(written(nvars)) - written=.false. variables => InCfg%get_variables() var_iter = variables%begin() @@ -622,7 +616,6 @@ SUBROUTINE read_and_write_rst (NTILES, SURFLAY, OutIsOld, NTILES_IN, idi, rc) if ( trim(var_name) == trim(names(j)) ) written(i) = .true. enddo if (trim(var_name) == "OLD_ITY" ) written(i) = .true. - if (trim(var_name) == "SNOWALB" ) written(i) = .true. call var_iter%next() From e30b751295048d33d1d0b5579744ccf63bbaa43c Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Thu, 1 Dec 2022 07:26:17 -0500 Subject: [PATCH 73/77] fix for plotting --- .../GEOSsurface_GridComp/Utils/Raster/clsm_plots.pro | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/clsm_plots.pro b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/clsm_plots.pro index a15739012..cfb19b470 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/clsm_plots.pro +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/clsm_plots.pro @@ -257,7 +257,7 @@ dy = NR/NR_plot catrow = lonarr(nc) cat = lonarr(nc,dy) -rst_file=path + '/rst/' + gfile+'.rst' +rst_file=path + '/rst/' + gfile+'*.rst' openr,1,rst_file,/F77_UNFORMATTED for j = 0l, NR_plot -1 do begin @@ -570,7 +570,7 @@ dy = NR/NR_movie cat = lonarr(nc,dy) catrow = lonarr(nc) -rst_file=path + '/rst/' + gfile+'.rst' +rst_file=path + '/rst/' + gfile+'*.rst' openr,1,rst_file,/F77_UNFORMATTED for j = 0l, NR_movie -1 do begin @@ -1340,7 +1340,7 @@ pfcr=0l cat =lonarr(nc) catp=lonarr(nc) -rst_file=path + '/rst/' + gfile+'.rst' +rst_file=path + '/rst/' + gfile+'*.rst' idum=0l openr,1,rst_file,/F77_UNFORMATTED @@ -1708,7 +1708,7 @@ dy = JM/NR catrow = lonarr (nc) tile_id = lonarr (NC, nr) -rst_file= path + '/rst/' + gfile+'.rst' +rst_file= path + '/rst/' + gfile+'*.rst' openr,1,rst_file,/F77_UNFORMATTED From b8ca44ba789b6e4b45aa91986e01a01719f3a4a8 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 1 Dec 2022 09:52:42 -0500 Subject: [PATCH 74/77] add information for the status of make_bcs.py --- .../GEOSsurface_GridComp/Utils/Raster/make_bcs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py index ea28515f8..e5b360083 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py @@ -72,5 +72,6 @@ def main(): if __name__ == '__main__' : + exit("Not ready") main() From c95cfb33e09eb3effebb8c750672f294eb202593 Mon Sep 17 00:00:00 2001 From: Rolf Reichle <54944691+gmao-rreichle@users.noreply.github.com> Date: Thu, 1 Dec 2022 09:55:35 -0500 Subject: [PATCH 75/77] edited exit message in make_bcs.py --- .../GEOSsurface_GridComp/Utils/Raster/make_bcs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py index e5b360083..b0466dd35 100755 --- a/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py +++ b/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/make_bcs.py @@ -72,6 +72,6 @@ def main(): if __name__ == '__main__' : - exit("Not ready") + exit("The python version of make_bcs is not yet ready for general use. Until further notice, please use csh script make_bcs") main() From 42aaa14895dc774bc11e6cc5dcfa22eebd3c3abc Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 1 Dec 2022 15:17:48 -0500 Subject: [PATCH 76/77] Move to use GitHub Action for Label Enforcement Due to changes at Heroku, we need to transition to use a GitHub Action for label enforcement. The current label enforcer no longer works, so PRs will be "stuck" until this is fixed. --- .github/workflows/enforce-labels.yml | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/enforce-labels.yml diff --git a/.github/workflows/enforce-labels.yml b/.github/workflows/enforce-labels.yml new file mode 100644 index 000000000..6e1720ef6 --- /dev/null +++ b/.github/workflows/enforce-labels.yml @@ -0,0 +1,29 @@ +name: Enforce PR Labels + +on: + pull_request: + types: [opened, labeled, unlabeled, edited, synchronize] + +jobs: + require-label: + runs-on: ubuntu-latest + steps: + - uses: mheap/github-action-required-labels@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + mode: minimum + count: 1 + labels: "0 diff,0 diff trivial,Non 0-diff,0 diff structural,0-diff trivial,Not 0-diff,0-diff,automatic,0-diff uncoupled" + add_comment: true + blocking-label: + runs-on: ubuntu-latest + steps: + - uses: mheap/github-action-required-labels@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + mode: exactly + count: 0 + labels: "Contingent - DNA,Needs Lead Approval,Contingent -- Do Not Approve" + add_comment: true From 6657d57077861b89e04f683de6115ce28a23d84d Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Fri, 2 Dec 2022 16:14:06 -0500 Subject: [PATCH 77/77] Update circleci to use 7.7.0 baselibs --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 275fdd3b0..010ae2d6b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 # Anchors to prevent forgetting to update a version -baselibs_version: &baselibs_version v7.5.0 +baselibs_version: &baselibs_version v7.7.0 bcs_version: &bcs_version v10.23.0 orbs: