#!/bin/tcsh -f # +-======-+ # Copyright (c) 2003-2007 United States Government as represented by # the Admistrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE, # REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN # COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE UNITED STATES GOVERNMENT AS # REPRESENTED BY THE GOVERNMENT AGENCY LISTED BELOW ("GOVERNMENT AGENCY"). # THE UNITED STATES GOVERNMENT, AS REPRESENTED BY GOVERNMENT AGENCY, IS AN # INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT DISTRIBUTIONS OR # REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES, # DISTRIBUTES, MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED # HEREIN, OR ANY PART THEREOF, IS, BY THAT ACTION, ACCEPTING IN FULL THE # RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT. # # Government Agency: National Aeronautics and Space Administration # Government Agency Original Software Designation: GSC-15354-1 # Government Agency Original Software Title: GEOS-5 GCM Modeling Software # User Registration Requested. Please Visit http://opensource.gsfc.nasa.gov # Government Agency Point of Contact for Original Software: # Dale Hithon, SRA Assistant, (301) 286-2691 # # +-======-+ ####################################################################### # Define Colors # Note: For No Colors, set C1 and C2 to "" ####################################################################### set BLACK = "\033[30m" set RED = "\033[31m" set GREEN = "\033[32m" set YELLOW = "\033[33m" set BLUE = "\033[34m" set MAGENTA = "\033[35m" set CYAN = "\033[36m" set WHITE = "\033[37m" set RESET = "\033[0m" set BOLD = "\033[1m" set C1 = $RED set C2 = $BLUE set C2 = $BLUE set CR = $RESET ####################################################################### # Find location of regrid utility # ------------------------------- set REGRID = `which $0` set root = `echo $REGRID | cut -d / -f1` if($root == . ) set REGRID = `echo $cwd`/regrid # Set GEOS Directories # -------------------- @ n = 1 set root = `echo $REGRID | cut -d"/" -f$n` while( .$root == . ) @ n = $n + 1 set root = `echo $REGRID | cut -d"/" -f$n` end setenv ESMADIR '' while( $root != 'src' ) setenv ESMADIR `echo ${ESMADIR}/${root}` @ n = $n + 1 set root = `echo $REGRID | cut -d / -f$n` end set GEOSSRC = $ESMADIR/src set GEOSUTIL = $GEOSSRC/GMAO_Shared/GEOS_Util set MK_RST = $GEOSSRC/GEOSgcs_GridComp/GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/GEOSland_GridComp/GEOScatch_GridComp/mk_restarts # Process Input String # -------------------- @ nmax = $#argv set nymd = NULL set nhms = NULL set im = NULL set jm = NULL set INDIR = NULL set OUTDIR = NULL set BCTAGI = NULL set BCTAGO = NULL set OCEANI = NULL set OCEANO = NULL set LAND = TRUE set ATMOS = TRUE set GRID = NULL set TILEI = NULL set TILEO = NULL @ n = 1 while( $n <= $nmax ) if( "$argv[$n]" == "-im" ) then @ n = $n + 1 set im = $argv[$n] endif if( "$argv[$n]" == "-jm" ) then @ n = $n + 1 set jm = $argv[$n] endif if( "$argv[$n]" == "-nymd" ) then @ n = $n + 1 set nymd = $argv[$n] endif if( "$argv[$n]" == "-nhms" ) then @ n = $n + 1 set nhms = $argv[$n] endif if( "$argv[$n]" == "-in" ) then @ n = $n + 1 set INDIR = $argv[$n] endif if( "$argv[$n]" == "-out" ) then @ n = $n + 1 set OUTDIR = $argv[$n] endif if( "$argv[$n]" == "-grid" ) then @ n = $n + 1 set GRID = $argv[$n] endif if( "$argv[$n]" == "-bctagi" ) then @ n = $n + 1 set BCTAGI = $argv[$n] endif if( "$argv[$n]" == "-bctago" ) then @ n = $n + 1 set BCTAGO = $argv[$n] endif if( "$argv[$n]" == "-tilei" ) then @ n = $n + 1 set TILEI = $argv[$n] endif if( "$argv[$n]" == "-tileo" ) then @ n = $n + 1 set TILEO = $argv[$n] endif if( "$argv[$n]" == "-land" ) then @ n = $n + 1 set LAND = $argv[$n] endif if( "$argv[$n]" == "-atmos" ) then @ n = $n + 1 set ATMOS = $argv[$n] endif if( "$argv[$n]" == "-oceani" ) then @ n = $n + 1 set OCEANI = $argv[$n] endif if( "$argv[$n]" == "-oceano" ) then @ n = $n + 1 set OCEANO = $argv[$n] endif @ n = $n + 1 end # Usage # ----- if( $nmax == 0 ) then echo " " cat $GEOSUTIL/post/regrid.README | more echo " " echo " " echo "Usage -- To regrid GEOS restarts: " echo "--------------------------------- " echo "regrid -in INPUT_DIRECTORY " echo " " echo " <-out OUTPUT_DIRECTORY> " echo " <-im IM> " echo " <-jm JM> " echo " <-grid GRID> " echo " <-oceani OCEANI> " echo " <-oceano OCEANO> " echo " <-bctagi BCTAGI> " echo " <-bctago BCTAGO> " echo " <-tilei TILEI> " echo " <-tileo TILEO> " echo " <-nymd YYYYMMDD> " echo " <-nhms HHMMSS> " echo " " echo " where:" echo " " echo " required:" echo " INPUT_DIRECTORY is the full pathname of the INPUT location" echo " " echo " optional:" echo " OUTPUT_DIRECTORY is the full pathname of the OUTPUT location" echo " IM is the Zonal Dimension Target" echo " JM is the Meridional Dimension Target" echo " GRID is the OUTPUT Grid, either L (Lat/Lon) or C (Cubed-Sphere)" echo " OCEANI is the INPUT Ocean Resolution, either O1 (1-deg, 360x180) or O8 (1/8-deg, 2880x1440)" echo " OCEANO is the OUTPUT Ocean Resolution, either O1 (1-deg, 360x180) or O8 (1/8-deg, 2880x1440)" echo " BCTAGI is the Tag Name used for the INPUT restarts" echo " BCTAGO is the Tag Name used for the OUTPUT restarts (Default: Ganymed-1_0_m2)" echo " TILEI is the full pathname of the TILE File to use (to overide file in BCTAGI)" echo " TILEO is the full pathname of the TILE File to use (to overide file in BCTAGO)" echo " YYYYMMDD is the Date (to help identify specific restarts in INPUT directory)" echo " HHMMSS is the Time (to help identify specific restarts in INPUT directory)" echo " " echo " Note: To regrid MERRA, use: -in MERRA" echo " All INPUT parameters are optional on the Command_Line except -in" echo " All OTHER parameters will be queried if needed" echo " " echo " " echo "------------------------------------------------------------------------------" echo " " echo "Enter the ${C1}INPUT${CR} directory contain the Model Restarts you want to regrid:" echo '(Note: To regrid from MERRA, simply enter: MERRA)' set INDIR = `echo $<` echo " " endif # INPUT Directory # --------------- echo " " if( $INDIR == NULL ) then echo " " echo "Enter the ${C1}INPUT${CR} directory contain the Model Restarts you want to regrid:" echo '(Note: To regrid from MERRA, simply enter: MERRA)' set INDIR = `echo $<` echo " " endif # Test if INPUT Directory is MERRA # -------------------------------- set MERRA = `echo $INDIR | tr "[:lower:]" "[:upper:]"` if( $MERRA == 'MERRA' & $nymd == 'NULL' ) then echo "Enter the ${C1}Date${CR} for MERRA regridding: ${C2}YYYYMMDD${CR}" set nymd = `echo $<` set nhms = 210000 echo " " endif # INPUT Boundary Condition Tag # ---------------------------- if( $MERRA == 'MERRA' ) then set BCTAGI = Fortuna-1_4 else if( $BCTAGI == 'NULL' ) then BCTAGI: echo "Enter the ${C1}Boundary Condition Tag${CR} used for your ${C1}INPUT${CR} restarts:" echo " Options: ${C2}Ganymed-1_0_D${CR} (Current Model with Data-Driven Great_Lakes)" echo " ${C2}Ganymed-1_0_M${CR} (Current Model with Model-Based Great_Lakes)" echo " ${C2}Ganymed-1_0_m2${CR} (GEOSadas-5_9_0 with Data-Driven Great_Lakes)" echo " ${C2}Ganymed-1_0_m1${CR} (GEOSadas-5_9_0 with Model-Based Great_Lakes)" echo " ${C2}Ganymed-1_0${CR} (GEOSadas-5_8_0)" echo " ${C2}Fortuna-2_1${CR} (GEOSadas-5_6_1 to GEOSadas-5_7_2)" echo " ${C2}Fortuna-2_0${CR}" echo " ${C2}Fortuna-1_5${CR}" echo " ${C2}Fortuna-1_4${CR} (MERRA)" set BCTAGI = `echo $<` if( .$BCTAGI == . ) goto BCTAGI if( $BCTAGI != 'Ganymed-1_0_D' & \ $BCTAGI != 'Ganymed-1_0_M' & \ $BCTAGI != 'Ganymed-1_0_m2' & \ $BCTAGI != 'Ganymed-1_0_m1' & \ $BCTAGI != 'Ganymed-1_0' & \ $BCTAGI != 'Fortuna-2_1' & \ $BCTAGI != 'Fortuna-2_0' & \ $BCTAGI != 'Fortuna-1_5' & \ $BCTAGI != 'Fortuna-1_4' ) goto BCTAGI else if( $BCTAGI != 'Ganymed-1_0_D' & \ $BCTAGI != 'Ganymed-1_0_M' & \ $BCTAGI != 'Ganymed-1_0_m2' & \ $BCTAGI != 'Ganymed-1_0_m1' & \ $BCTAGI != 'Ganymed-1_0' & \ $BCTAGI != 'Fortuna-2_1' & \ $BCTAGI != 'Fortuna-2_0' & \ $BCTAGI != 'Fortuna-1_5' & \ $BCTAGI != 'Fortuna-1_4' ) then echo 'Incorrect specification of BCTAGI' exit endif endif endif # INPUT Ocean Resolution # ---------------------- if( $MERRA == 'MERRA' ) then set SST_IMI = 360 set SST_JMI = 180 else if( $BCTAGI == 'Fortuna-1_4' ) set OCEANI = o1 if( $BCTAGI == 'Fortuna-1_5' ) set OCEANI = o1 if( $BCTAGI == 'Fortuna-2_0' ) set OCEANI = o1 if( $BCTAGI == 'Fortuna-2_1' ) set OCEANI = o1 if( $BCTAGI == 'Ganymed-1_0' ) set OCEANI = o1 OCEANI: if( $OCEANI == NULL ) then echo "Enter the ${C1}INPUT OCEAN${CR} Resolution to use: ${C2}O1${CR} (1 -deg -- 360x180)" echo " ${C2}O8${CR} (1/8-deg -- 2880x1440)" set OCEANI = `echo $<` endif set OCEANI = `echo $OCEANI | tr "[:lower:]" "[:upper:]"` if( .$OCEANI != .O1 & .$OCEANI != .O8 ) then set OCEANI = NULL goto OCEANI endif echo " " endif if( $OCEANI == O1 ) then set SST_IMI = 360 set SST_JMI = 180 endif if( $OCEANI == O4 ) then set SST_IMI = 1440 set SST_JMI = 720 endif if( $OCEANI == O8 ) then set SST_IMI = 2880 set SST_JMI = 1440 endif endif # OUTPUT Directory # ---------------- if( $OUTDIR == NULL ) then if( $MERRA != MERRA ) then set OUTDIR_def = $INDIR else set OUTDIR_def = '' endif OUTDIR: echo "Enter the ${C1}OUTPUT${CR} directory location:" if( $MERRA != MERRA ) echo "(Default: $INDIR)" set OUTDIR = `echo $<` if( .$OUTDIR == . ) then if( .$OUTDIR_def != . ) then set OUTDIR = $OUTDIR_def else goto OUTDIR endif endif echo " " endif # ATMOS OUTPUT Resolution # ----------------------- if( $im == NULL | $jm == NULL) then HRCODE: echo "Enter the ${C1}Atmospheric Horizontal Resolution${CR} code you want to create:" echo " ${C2}b${CR} -- 2 deg" echo " ${C2}c${CR} -- 1 deg" echo " ${C2}d${CR} -- 1/2 deg" echo " ${C2}e${CR} -- 1/4 deg" echo " ${C2}o${CR} -- other " set HRCODE = `echo $<` set LMCODE = `echo $HRCODE | cut -c2-` set HRCODE = `echo $HRCODE | tr "[:upper:]" "[:lower:]" | cut -c1` if( $HRCODE != 'b' & \ $HRCODE != 'c' & \ $HRCODE != 'd' & \ $HRCODE != 'e' & \ $HRCODE != 'o' ) goto HRCODE if( $HRCODE != 'o' ) then set GRID = `echo $GRID | tr "[:lower:]" "[:upper:]"` GRID: if( $GRID == 'NULL' ) then echo "Enter the ${C1}Grid${CR} to use: ${C2}L (Lat-Lon)${CR} or ${C2}C (Cubed-Sphere)${CR}" set GRID = `echo $<` set GRID = `echo $GRID | tr "[:lower:]" "[:upper:]"` endif if( $GRID != 'L' & \ $GRID != 'C' ) then set GRID = 'NULL' goto GRID endif if( $GRID == 'C' ) then if( $HRCODE == 'b' ) set Resolution = 'c48' if( $HRCODE == 'c' ) set Resolution = 'c90' if( $HRCODE == 'd' ) set Resolution = 'c180' if( $HRCODE == 'e' ) set Resolution = 'c360' else if( $HRCODE == 'b' ) set Resolution = `echo 144 91` if( $HRCODE == 'c' ) set Resolution = `echo 288 181` if( $HRCODE == 'd' ) set Resolution = `echo 576 361` if( $HRCODE == 'e' ) set Resolution = `echo 1152 721` endif else echo "Enter the Atmospheric Lat/Lon Horizontal Resolution: IM JM" echo " or ..... the Cubed-Sphere Resolution: cNN" set Resolution = `echo $<` endif if( $#Resolution == 2 ) then set im = $Resolution[1] set jm = $Resolution[2] else if (`echo $Resolution[1] | cut -b1` == "c" ) then set im = `echo $Resolution[1] | cut -c2-` else set im = $Resolution[1] endif @ jm = 6 * $im endif endif # Check for Output Cubed-Sphere # ----------------------------- set cubeo = FALSE @ RAT = ${jm} / ${im} if (${RAT} == 6) then set cubeo = TRUE endif # OUTPUT Boundary Condition Tag # ----------------------------- if( $BCTAGO == 'NULL' ) then BCTAGO: echo "Enter the ${C1}Boundary Condition Tag${CR} used for your ${C1}OUTPUT${CR} restarts:" echo " Options: ${C2}Ganymed-1_0_D${CR} (Current Model with Data-Driven Great_Lakes)" echo " ${C2}Ganymed-1_0_M${CR} (Current Model with Model-Based Great_Lakes)" echo " ${C2}Ganymed-1_0_m2${CR} (GEOSadas-5_9_0 with Data-Driven Great_Lakes)" echo " ${C2}Ganymed-1_0_m1${CR} (GEOSadas-5_9_0 with Model-Based Great_Lakes)" echo " ${C2}Ganymed-1_0${CR} (GEOSadas-5_8_0)" if( $cubeo == FALSE ) then echo " ${C2}Fortuna-2_1${CR} (GEOSadas-5_6_1 to GEOSadas-5_7_2)" echo " ${C2}Fortuna-2_0${CR}" echo " ${C2}Fortuna-1_5${CR}" echo " ${C2}Fortuna-1_4${CR} (MERRA)" endif set BCTAGO = `echo $<` if( .$BCTAGO == . ) goto BCTAGO if( $BCTAGO != 'Ganymed-1_0_D' & \ $BCTAGO != 'Ganymed-1_0_M' & \ $BCTAGO != 'Ganymed-1_0_m2' & \ $BCTAGO != 'Ganymed-1_0_m1' & \ $BCTAGO != 'Ganymed-1_0' & \ $BCTAGO != 'Fortuna-2_1' & \ $BCTAGO != 'Fortuna-2_0' & \ $BCTAGO != 'Fortuna-1_5' & \ $BCTAGO != 'Fortuna-1_4' ) goto BCTAGO else if( $BCTAGO != 'Ganymed-1_0_D' & \ $BCTAGO != 'Ganymed-1_0_M' & \ $BCTAGO != 'Ganymed-1_0_m2' & \ $BCTAGO != 'Ganymed-1_0_m1' & \ $BCTAGO != 'Ganymed-1_0' & \ $BCTAGO != 'Fortuna-2_1' & \ $BCTAGO != 'Fortuna-2_0' & \ $BCTAGO != 'Fortuna-1_5' & \ $BCTAGO != 'Fortuna-1_4' ) then echo 'Incorrect specification of BCTAGO' exit endif endif # OUTPUT Ocean Resolution # ----------------------- if( $BCTAGO == 'Fortuna-1_4' ) set OCEANO = o1 if( $BCTAGO == 'Fortuna-1_5' ) set OCEANO = o1 if( $BCTAGO == 'Fortuna-2_0' ) set OCEANO = o1 if( $BCTAGO == 'Fortuna-2_1' ) set OCEANO = o1 if( $BCTAGO == 'Ganymed-1_0' ) set OCEANO = o1 OCEANO: if( $OCEANO == NULL ) then echo "Enter the ${C1}OUTPUT OCEAN${CR} Resolution to use: ${C2}O1${CR} (1 -deg -- 360x180)" echo " ${C2}O8${CR} (1/8-deg -- 2880x1440)" set OCEANO = `echo $<` endif set OCEANO = `echo $OCEANO | tr "[:lower:]" "[:upper:]"` if( .$OCEANO != .O1 & .$OCEANO != .O8 ) then set OCEANO = NULL goto OCEANO endif echo " " endif if( $OCEANO == O1 ) then set SST_IMO = 360 set SST_JMO = 180 endif if( $OCEANO == O4 ) then set SST_IMO = 1440 set SST_JMO = 720 endif if( $OCEANO == O8 ) then set SST_IMO = 2880 set SST_JMO = 1440 endif # -------------------------------- set datetime = `date +%Y%m%d_%H%M%S` set OUTPUT = $OUTDIR/$datetime if(! -e $OUTPUT ) mkdir -p $OUTPUT # ----------------------------- # MERRA Case # ---------- if( $MERRA == 'MERRA' ) then set year = `echo $nymd | cut -c1-4` set month = `echo $nymd | cut -c5-6` set day = `echo $nymd | cut -c7-8` if( $year < 1979 ) then echo " " echo Data is not available before 1979 \! echo " " exit else if ($year < 1989 ) then set archive = /archive/g_proj5/production/GEOSdas-2_1_4/d5_merra_jan79/rs/Y$year/M$month set stream = d5_merra_jan79 else if ($year < 1998 ) then set archive = /archive/g_proj5/production/GEOSdas-2_1_4/d5_merra_jan89/rs/Y$year/M$month set stream = d5_merra_jan89 else set archive = /archive/g_proj5/production/GEOSdas-2_1_4/d5_merra_jan98/rs/Y$year/M$month set stream = d5_merra_jan98 endif set files = `echo fvcore_internal_rst moist_internal_rst catch_internal_rst lake_internal_rst landice_internal_rst saltwater_internal_rst agcm_import_rst pchem_internal_rst` set found = true foreach file ($files) if(! -e $archive/$stream.$file.${nymd}_21z.bin ) then echo "Could not locate "$archive/$stream.$file.${nymd}_21z.bin set found = false endif end if( $found == false ) then echo " " echo Date: $nymd is not available \! echo " " echo Available Nearby Dates: set date = `$GEOSUTIL/post/tick $nymd 210000 -864000` set nymd = $date[1] @ NDAY = 1 while( $NDAY <= 21 ) set year = `echo $nymd | cut -c1-4` set month = `echo $nymd | cut -c5-6` set day = `echo $nymd | cut -c7-8` if( $year >= 1979 ) then if ($year < 1989 ) then set archive = /archive/g_proj5/production/GEOSdas-2_1_4/d5_merra_jan79/rs/Y$year/M$month set stream = d5_merra_jan79 else if ($year < 1998 ) then set archive = /archive/g_proj5/production/GEOSdas-2_1_4/d5_merra_jan89/rs/Y$year/M$month set stream = d5_merra_jan89 else set archive = /archive/g_proj5/production/GEOSdas-2_1_4/d5_merra_jan98/rs/Y$year/M$month set stream = d5_merra_jan98 endif set files = `echo fvcore_internal_rst moist_internal_rst catch_internal_rst lake_internal_rst landice_internal_rst saltwater_internal_rst` set found = true foreach file ($files) if(! -e $archive/$stream.$file.${nymd}_21z.bin ) set found = false end endif if( $found == true ) echo " $nymd 210000" set date = `$GEOSUTIL/post/tick $nymd 210000 86400` set nymd = $date[1] @ NDAY = $NDAY + 1 end echo " " exit else echo " " echo "Getting MERRA Data (Please wait) ... " foreach file ($files) echo dmget $archive/$stream.$file.${nymd}_21z.bin ... dmget $archive/$stream.$file.${nymd}_21z.bin & end wait echo "Done." endif set BC_TAG = ${BCTAGI} set DYN = $archive/$stream.fvcore_internal_rst.${nymd}_21z.bin set MOIST = $archive/$stream.moist_internal_rst.${nymd}_21z.bin set CATCH = $archive/$stream.catch_internal_rst.${nymd}_21z.bin set LAKE = $archive/$stream.lake_internal_rst.${nymd}_21z.bin set LANDICE = $archive/$stream.landice_internal_rst.${nymd}_21z.bin set SALT = $archive/$stream.saltwater_internal_rst.${nymd}_21z.bin set AGCM = $archive/$stream.agcm_import_rst.${nymd}_21z.bin set PCHEM = $archive/$stream.pchem_internal_rst.${nymd}_21z.bin set GOCART = '' set OCEANI = o1 set IM_OLD = 540 set JM_OLD = 361 set IM_NEW = $im set JM_NEW = $jm endif # NON-MERRA Case # -------------- if( $MERRA != 'MERRA' ) then set types = "fvcore_internal \ moist_internal \ catch_internal \ lake_internal \ landice_internal \ saltwater_internal \ pchem_internal \ gocart_internal \ agcm_import" set types = `echo $types` foreach type ($types) set files = `/bin/ls -1 $INDIR/*${type}_rst*` if( $#files > 1 ) then if( $nymd == 'NULL') then echo "Enter the Date for regridding: YYYYMMDD" set nymd = `echo $<` endif set files = `/bin/ls -1 $INDIR/*${type}_rst*${nymd}*` if( $#files > 1 ) then if( $nhms == 'NULL') then echo "Enter the Time for regridding: HHMMDD" set nhms = `echo $<` endif set hour = `echo $nhms | cut -c1-2` set files = `/bin/ls -1 $INDIR/*${type}_rst*${nymd}*${hour}*` if( $#files > 1 ) then echo "Insufficient information for unique TYPE: $type" echo "Move INPUT restarts to isolated directory." exit endif endif endif if( $#files == 1 ) then set ${type}_rst = $files[1] else set ${type}_rst = '' endif end # Required Restarts # ----------------- echo ' ' set NOGO = FALSE if( .${fvcore_internal_rst} == . ) then echo "Cannot find restart files in $INDIR directory for TYPE: fvcore_internal_rst" set NOGO = TRUE endif if( .${moist_internal_rst} == . ) then echo "Cannot find restart files in $INDIR directory for TYPE: moist_internal_rst" set NOGO = TRUE endif if( .${catch_internal_rst} == . ) then echo "Cannot find restart files in $INDIR directory for TYPE: catch_internal_rst" set NOGO = TRUE endif if( .${lake_internal_rst} == . ) then echo "Cannot find restart files in $INDIR directory for TYPE: lake_internal_rst" set NOGO = TRUE endif if( .${landice_internal_rst} == . ) then echo "Cannot find restart files in $INDIR directory for TYPE: landice_internal_rst" set NOGO = TRUE endif if( .${saltwater_internal_rst} == . ) then echo "Cannot find restart files in $INDIR directory for TYPE: saltwater_internal_rst" set NOGO = TRUE endif if( $NOGO == TRUE ) then echo ' ' exit endif set FVHEAD = ` $GEOSUTIL/post/fvrst.x -h ${fvcore_internal_rst}` set IM_OLD = $FVHEAD[1] set JM_OLD = $FVHEAD[2] set LM_OLD = $FVHEAD[3] set nymd = $FVHEAD[4] set nhms = $FVHEAD[5] set cubei = FALSE @ RAT = ${JM_OLD} / ${IM_OLD} if (${RAT} == 6) then set cubei = TRUE endif if( $cubei == TRUE ) then echo "${C1}Current script CANNOT regrid INPUT restarts on the cube\!${CR}" echo ' ' exit endif set BC_TAG = ${BCTAGI} set DYN = ${fvcore_internal_rst} set MOIST = ${moist_internal_rst} set CATCH = ${catch_internal_rst} set LAKE = ${lake_internal_rst} set LANDICE = ${landice_internal_rst} set SALT = ${saltwater_internal_rst} set AGCM = ${agcm_import_rst} set PCHEM = ${pchem_internal_rst} set GOCART = ${gocart_internal_rst} set IM_NEW = $im set JM_NEW = $jm endif # ---------------------------- ####################################################################### # Proceed ... ####################################################################### # Check for completeness # ---------------------- set NOGO = FALSE if( .$BC_TAG == . ) then echo You must supply the INPUT boundary condition tag: BC_TAG set NOGO = TRUE endif if( .$IM_OLD == . ) then echo You must supply the INPUT zonal dimension: IM_OLD set NOGO = TRUE endif if( .$JM_OLD == . ) then echo You must supply the INPUT meridional dimension: JM_OLD set NOGO = TRUE endif if( .$DYN == . & ATMOS == TRUE ) then echo You must supply the INPUT: DYN_INTERNAL_RESTART_FILE set NOGO = TRUE endif if( .$MOIST == . & ATMOS == TRUE ) then echo You must supply the INPUT: MOIST_INTERNAL_RESTART_FILE set NOGO = TRUE endif if( .$CATCH == . & LAND == TRUE ) then echo You must supply the INPUT: CATCH_INTERNAL_RESTART_FILE set NOGO = TRUE endif if( .$LAKE == . & LAND == TRUE ) then echo You must supply the INPUT: LAKE_INTERNAL_RESTART_FILE set NOGO = TRUE endif if( .$LANDICE == . & LAND == TRUE ) then echo You must supply the INPUT: LANDICE_INTERNAL_RESTART_FILE set NOGO = TRUE endif if( .$SALT == . & LAND == TRUE ) then echo You must supply the INPUT: SALT_INTERNAL_RESTART_FILE set NOGO = TRUE endif if( .$IM_NEW == . ) then echo You must supply the OUTPUT zonal dimension: IM_NEW set NOGO = TRUE endif if( .$JM_NEW == . ) then echo You must supply the OUTPUT meridional dimension: JM_NEW set NOGO = TRUE endif if( $NOGO == TRUE ) exit set GCM_IM_OLD = `echo ${IM_OLD} | awk '{printf "%4.4i", $1}'` set GCM_JM_OLD = `echo ${JM_OLD} | awk '{printf "%4.4i", $1}'` set SST_IM_OLD = `echo ${SST_IMI} | awk '{printf "%4.4i", $1}'` set SST_JM_OLD = `echo ${SST_JMI} | awk '{printf "%4.4i", $1}'` set GCM_IM_NEW = `echo ${IM_NEW} | awk '{printf "%4.4i", $1}'` set GCM_JM_NEW = `echo ${JM_NEW} | awk '{printf "%4.4i", $1}'` set SST_IM_NEW = `echo ${SST_IMO} | awk '{printf "%4.4i", $1}'` set SST_JM_NEW = `echo ${SST_JMO} | awk '{printf "%4.4i", $1}'` set RSLV_OLD = ${IM_OLD}x${JM_OLD} set RSLV_NEW = ${IM_NEW}x${JM_NEW} if( $BCTAGI == 'Ganymed-1_0' | \ $BCTAGI == 'Fortuna-2_1' | \ $BCTAGI == 'Fortuna-2_0' | \ $BCTAGI == 'Fortuna-1_5' | \ $BCTAGI == 'Fortuna-1_4' ) then set BCS_OLD = /discover/nobackup/ltakacs/bcs/$BC_TAG/$RSLV_OLD if( $TILEI != 'NULL' ) then set TILE_OLD = $TILEI else set TILE_OLD = $BCS_OLD/FV_${RSLV_OLD}_DC_${SST_IMI}x${SST_JMI}_DE.til endif set TOPO_OLD = $BCS_OLD/topo_DYN_ave_${RSLV_OLD}_DC.data else set BCS_OLD = /discover/nobackup/ltakacs/bcs/$BC_TAG/DC${GCM_IM_OLD}xPC${GCM_JM_OLD}_DE${SST_IM_OLD}xPE${SST_JM_OLD} if( $TILEI != 'NULL' ) then set TILE_OLD = $TILEI else set TILE_OLD = $BCS_OLD/DC${GCM_IM_OLD}xPC${GCM_JM_OLD}_DE${SST_IM_OLD}xPE${SST_JM_OLD}-Pfafstetter.til endif set TOPO_OLD = $BCS_OLD/topo_DYN_ave_${RSLV_OLD}_DC.data endif if( $BCTAGO == 'Ganymed-1_0' | \ $BCTAGO == 'Fortuna-2_1' | \ $BCTAGO == 'Fortuna-2_0' | \ $BCTAGO == 'Fortuna-1_5' | \ $BCTAGO == 'Fortuna-1_4' ) then set BCS_NEW = /discover/nobackup/ltakacs/bcs/$BCTAGO/$RSLV_NEW set TOPO_NEW = $BCS_NEW/topo_DYN_ave_${RSLV_NEW}_DC.data if( $TILEO != 'NULL' ) then set TILE_NEW = $TILEO else set TILE_NEW = $BCS_NEW/FV_${RSLV_NEW}_DC_${SST_IMO}x${SST_JMO}_DE.til endif set DIM_TAG = DC${GCM_IM_NEW}xPC${GCM_JM_NEW}_DE${SST_IM_NEW}xPE${SST_JM_NEW} else set BCS_NEW = /discover/nobackup/ltakacs/bcs/$BCTAGO/DC${GCM_IM_NEW}xPC${GCM_JM_NEW}_DE${SST_IM_NEW}xPE${SST_JM_NEW} set TOPO_NEW = $BCS_NEW/topo_DYN_ave_${RSLV_NEW}_DC.data if( $TILEO != 'NULL' ) then set TILE_NEW = $TILEO else set TILE_NEW = $BCS_NEW/DC${GCM_IM_NEW}xPC${GCM_JM_NEW}_DE${SST_IM_NEW}xPE${SST_JM_NEW}-Pfafstetter.til endif set DIM_TAG = DC${GCM_IM_NEW}xPC${GCM_JM_NEW}_DE${SST_IM_NEW}xPE${SST_JM_NEW} endif if ($cubeo == TRUE) then set RSLV_NEW = ${IM_NEW}x${JM_NEW} set C_NPX = `echo $IM_NEW | awk '{printf "%4.4i", $1}'` set C_NPY = `echo $JM_NEW | awk '{printf "%5.5i", $1}'` set O_NPX = `echo ${SST_IMO} | awk '{printf "%4.4i", $1}'` set O_NPY = `echo ${SST_JMO} | awk '{printf "%4.4i", $1}'` if( $BCTAGO == 'Ganymed-1_0' ) then set BCS_NEW = /discover/nobackup/ltakacs/bcs/$BCTAGO/c${IM_NEW} if( $TILEO != 'NULL' ) then set TILE_NEW = $TILEO else set TILE_NEW = $BCS_NEW/CF${C_NPX}x6C${C_NPY}_DE${O_NPX}xPE${O_NPY}_Pfafstetter.til endif else set BCS_NEW = /discover/nobackup/ltakacs/bcs/$BCTAGO/CF${C_NPX}x6C_DE${O_NPX}xPE${O_NPY} if( $TILEO != 'NULL' ) then set TILE_NEW = $TILEO else set TILE_NEW = $BCS_NEW/CF${C_NPX}x6C_DE${O_NPX}xPE${O_NPY}-Pfafstetter.til endif endif set TOPO_NEW = $BCS_NEW/topo_DYN_ave_${RSLV_NEW}.data set DIM_TAG = CF${C_NPX}x6C_DE${O_NPX}xPE${O_NPY} endif echo "" echo "Regridding Restarts from: ${C2}$INDIR${CR}" echo " Output Location: ${C2}$OUTDIR${CR}" echo "" echo " Input ATMOS Resolution: ${C2}$IM_OLD $JM_OLD${CR}" echo " Input OCEAN Resolution: ${C2}$SST_IMI $SST_JMI${CR}" echo " Input BC Tag: ${C2}$BCTAGI${CR}" echo " Input TILE File: ${C2}$TILE_OLD${CR}" echo "" echo " Output ATMOS Resolution: ${C2}$IM_NEW $JM_NEW${CR}" echo " Output OCEAN Resolution: ${C2}$SST_IMO $SST_JMO${CR}" echo " Output BC Tag: ${C2}$BCTAGO${CR}" echo " Output TILE File: ${C2}$TILE_NEW${CR}" echo "" echo " Input Date: ${C2}$nymd${CR}" echo " Input Time: ${C2}$nhms${CR}" echo "" cd $OUTPUT set files = `/bin/ls -1 $DYN $MOIST $AGCM $PCHEM $GOCART $CATCH $LAKE $LANDICE $SALT` foreach file ($files) if( -e `basename $file` ) /bin/rm -f `basename $file` end set files = `/bin/ls -1 $DYN $MOIST $AGCM $PCHEM $GOCART` foreach file ($files) /bin/cp $file . end set DYN = `basename $DYN` set MOIST = `basename $MOIST` if( .$AGCM != . ) set AGCM = `basename $AGCM` if( .$PCHEM != . ) set PCHEM = `basename $PCHEM` if( .$GOCART != . ) set GOCART = `basename $GOCART` if ($cubeo != TRUE) then if(! -e $GEOSUTIL/post/rs_hinterp.x ) then cd $GEOSUTIL/post gmake install rs_hinterp.x rehash cd $OUTPUT endif $GEOSUTIL/post/rs_hinterp.x -dyn $DYN \ -moist $MOIST \ -topo_old $TOPO_OLD \ -topo_new $TOPO_NEW \ -im $IM_NEW -jm $JM_NEW \ -other $AGCM $PCHEM $GOCART set files = `/bin/ls -1 $DYN $MOIST $AGCM $PCHEM $GOCART` foreach file ($files) if( -e $file ) /bin/rm -f $file end else if ($cubeo == TRUE) then echo "The Cubed-Sphere regridding is MPI based; submitting job to PBS" if($IM_NEW == "48") then setenv NODES 1 setenv NPE 12 setenv QUEUE general_small endif if($IM_NEW == "90") then setenv NODES 1 setenv NPE 12 setenv QUEUE general_small endif if($IM_NEW == "180") then setenv NODES 2 setenv NPE 24 setenv QUEUE general endif if($IM_NEW == "360") then setenv NODES 4 setenv NPE 48 setenv QUEUE general endif if($IM_NEW == "500") then setenv NODES 4 setenv NPE 48 setenv QUEUE general endif if($IM_NEW == "720") then setenv NODES 8 setenv NPE 96 setenv QUEUE general endif if($IM_NEW == "1000") then setenv NODES 16 setenv NPE 192 setenv QUEUE general endif if($IM_NEW == "1440") then setenv NODES 16 setenv NPE 192 setenv QUEUE general endif if($IM_NEW == "2000") then setenv NODES 32 setenv NPE 384 setenv QUEUE general endif if($IM_NEW == "2880") then setenv NODES 64 setenv NPE 768 setenv QUEUE general endif if(-e regrid.j) /bin/rm regrid.j cat > regrid.j << EOF #!/bin/csh -xf #PBS -l walltime=1:00:00 #PBS -l select=${NODES}:ncpus=12:mpiprocs=12 #PBS -N regrid #PBS -q ${QUEUE} #PBS -j oe cd $OUTPUT source $ESMADIR/src/g5_modules /bin/ln -s $DYN fvcore_internal_restart_in /bin/ln -s $MOIST moist_internal_restart_in /bin/ln -s $TOPO_OLD . /bin/ln -s $TOPO_NEW topo_DYN_ave_${IM_NEW}x${JM_NEW}.data if( ".$AGCM" != . ) /bin/ln -s $AGCM agcm_import_restart_in if( ".$PCHEM" != . ) /bin/ln -s $PCHEM pchem_internal_restart_in if( ".$GOCART" != . ) /bin/ln -s $GOCART gocart_internal_restart_in # The MERRA fvcore_internal_restarts don't include W or DZ, but we can add them by setting # HYDROSTATIC = 0 which means HYDROSTATIC = FALSE set HYDROSTATIC = 0 if (\$?I_MPI_ROOT) then setenv I_MPI_FABRICS "shm:ofa" setenv I_MPI_RDMA_SCALABLE_PROGRESS enable setenv I_MPI_USE_DYNAMIC_CONNECTIONS disable setenv I_MPI_JOB_STARTUP_TIMEOUT 10000 setenv DAPL_ACK_RETRY 7 setenv DAPL_ACK_TIMER 23 setenv DAPL_RNR_RETRY 7 setenv DAPL_RNR_TIMER 28 setenv I_MPI_RDMA_RNDV_WRITE enable #intel scaling suggestions setenv DAPL_CM_ARP_TIMEOUT_MS 8000 setenv DAPL_CM_ARP_RETRY_COUNT 25 setenv DAPL_CM_ROUTE_TIMEOUT_MS 20000 setenv DAPL_CM_ROUTE_RETRY_COUNT 15 setenv DAPL_MAX_CM_RESPONSE_TIME 20 setenv DAPL_MAX_CM_RETRIES 15 # setenv I_MPI_STATS 4 mpirun -perhost 12 -np $NPE $ESMADIR/Linux/bin/interp_restarts.x -999 $IM_NEW $IM_NEW 72 \$HYDROSTATIC else if (\$?MVAPICH2) then setenv MV2_ENABLE_AFFINITY 0 mpirun -prepend-rank -launcher-exec /usr/bin/sshmpi -binding cpu:sockets -topolib hwloc -f \${PBS_NODEFILE} -np $NPE $ESMADIR/Linux/bin/interp_restarts.x -999 $IM_NEW $IM_NEW 72 \$HYDROSTATIC endif endif exit EOF # Run or Submit Cubed-Sphere Regrid script # ---------------------------------------- if ($?PBS_NODEFILE) then chmod +x regrid.j ./regrid.j else qsub -W block=true regrid.j endif else echo "Unknown grid type" exit endif ####################################################################### # LAND Regridding ####################################################################### if( $LAND == TRUE ) then mkdir land cd land /bin/cp -r $MK_RST . cd mk_restarts/InData set files = `/bin/ls -1 | grep -v CVS | grep -v README` foreach file ($files) /bin/rm -f $file end /bin/ln -s $TILE_OLD . /bin/cp $CATCH . /bin/cp $LAKE . /bin/cp $LANDICE . /bin/cp $SALT . cd ../OutData set files = `/bin/ls -1 | grep -v CVS | grep -v README` foreach file ($files) /bin/rm -f $file end if( -e clsm ) /bin/rm -r clsm /bin/ln -s $TILE_NEW . /bin/ln -s $BCS_NEW/clsm . cd ../ ./mk_Restarts cd OutData set CATCH = `basename $CATCH` set LAKE = `basename $LAKE` set LANDICE = `basename $LANDICE` set SALT = `basename $SALT` /bin/mv $CATCH $OUTPUT/$CATCH.$BCTAGO.$DIM_TAG /bin/mv $LAKE $OUTPUT/$LAKE.$BCTAGO.$DIM_TAG /bin/mv $LANDICE $OUTPUT/$LANDICE.$BCTAGO.$DIM_TAG /bin/mv $SALT $OUTPUT/$SALT.$BCTAGO.$DIM_TAG if ($cubeo == TRUE) then set rslv_tag = ${IM_NEW}x${JM_NEW} else set rslv_tag = ${IM_NEW}x${JM_NEW}_DC endif set vegsiz = `/bin/ls -l vegdyn_internal_rst | cut -d' ' -f5` cmp -n $vegsiz vegdyn_internal_rst $BCS_NEW/vegdyn_${rslv_tag}.dat set RC = $status if( $RC == 0 ) then echo ' ' echo ${C2}vegdyn_internal_rst is consistent with boundary condition file:${CR} echo $BCS_NEW/vegdyn_${rslv_tag}.dat /bin/rm -f vegdyn_internal_rst endif if( $RC == 1 ) then echo ' ' echo ${C2}vegdyn_internal_rst is ${CR}${C1}NOT${CR}${C2} consistent with boundary condition file:${CR} echo $BCS_NEW/vegdyn_${rslv_tag}.dat /bin/mv vegdyn_internal_rst $OUTPUT/vegdyn_${rslv_tag}.dat.$BCTAGO.$DIM_TAG endif if( $RC == 2 ) then echo ' ' echo ${C2}Note: vegdyn_internal_rst boundary condition file does ${CR}${C1}NOT${CR}${C2} exist.${CR} /bin/mv vegdyn_internal_rst $OUTPUT/vegdyn_${rslv_tag}.dat.$BCTAGO.$DIM_TAG endif echo ' ' # Check for CATCH Rescaling # ------------------------- if( $BCTAGI == 'Ganymed-1_0' | \ $BCTAGI == 'Fortuna-2_1' | \ $BCTAGI == 'Fortuna-2_0' | \ $BCTAGI == 'Fortuna-1_5' | \ $BCTAGI == 'Fortuna-1_4' ) then if( $BCTAGO != 'Ganymed-1_0' & \ $BCTAGO != 'Fortuna-2_1' & \ $BCTAGO != 'Fortuna-2_0' & \ $BCTAGO != 'Fortuna-1_5' & \ $BCTAGO != 'Fortuna-1_4' ) then echo " " echo "${C2}Scaling of CATCH_INTERNAL_RESTART will be performed ...${CR}" echo "-------------------------------------------------------" /bin/mv $OUTPUT/$CATCH.$BCTAGO.${DIM_TAG} $OUTPUT/$CATCH.$BCTAGO.${DIM_TAG}.orig ../Scale_Catch ../InData/$CATCH $OUTPUT/$CATCH.$BCTAGO.${DIM_TAG}.orig catch_internal_rst.scaled if( "$status" != "0" ) then echo " " echo " ${C1}Scaling of CATCH_INTERNAL_RESTART Failed\!${CR}" echo " ${C1}-----------------------------------------${CR}" echo " ${C1}Note that ${C2}BOTH${CR} Atmospheric Grid Resolutions${CR}" echo " ${C2}AND${CR} ${C1}Tile Ordering must be IDENTICAL${CR}" echo " " exit 1 else /bin/mv catch_internal_rst.scaled $OUTPUT/$CATCH.$BCTAGO.${DIM_TAG} endif endif endif ####################################################################### # Move Output ####################################################################### set IM = $IM_NEW if( $IM < 1000 ) set IM = 0$IM if( $IM < 100 ) set IM = 0$IM set JM = $JM_NEW if( $JM < 1000 ) set JM = 0$JM if( $JM < 100 ) set JM = 0$JM cd $OUTPUT if (-e ${DYN}.${IM}x${JM} ) /bin/mv ${DYN}.${IM}x${JM} ${DYN}.$BCTAGO.$DIM_TAG if (-e ${MOIST}.${IM}x${JM} ) /bin/mv ${MOIST}.${IM}x${JM} ${MOIST}.$BCTAGO.$DIM_TAG if (-e ${PCHEM}.${IM}x${JM} ) /bin/mv ${PCHEM}.${IM}x${JM} ${PCHEM}.$BCTAGO.$DIM_TAG if (-e ${GOCART}.${IM}x${JM} ) /bin/mv ${GOCART}.${IM}x${JM} ${GOCART}.$BCTAGO.$DIM_TAG if (-e ${AGCM}.${IM}x${JM} ) /bin/mv ${AGCM}.${IM}x${JM} ${AGCM}.$BCTAGO.$DIM_TAG if (-e fvcore_internal_rst_c${IM}_072L) /bin/mv fvcore_internal_rst_c${IM}_072L ${DYN}.$BCTAGO.$DIM_TAG if (-e moist_internal_rst_c${IM}_072L) /bin/mv moist_internal_rst_c${IM}_072L ${MOIST}.$BCTAGO.$DIM_TAG if (-e pchem_internal_rst_c${IM}_072L) /bin/mv pchem_internal_rst_c${IM}_072L ${PCHEM}.$BCTAGO.$DIM_TAG if (-e gocart_internal_rst_c${IM}_072L) /bin/mv gocart_internal_rst_c${IM}_072L ${GOCART}.$BCTAGO.$DIM_TAG if (-e agcm_import_rst_c${IM}_072L) /bin/mv agcm_import_rst_c${IM}_072L ${AGCM}.$BCTAGO.$DIM_TAG if( -e land ) /bin/rm -r land /bin/mv *.${DIM_TAG} $OUTDIR if( -e vegdyn_${rslv_tag}.dat.$BCTAGO.$DIM_TAG ) /bin/mv vegdyn_${rslv_tag}.dat.$BCTAGO.$DIM_TAG $OUTDIR cd $OUTDIR /bin/rm -r $OUTPUT # Reiterate Results # ----------------- echo "" echo "Regridding Restarts from: ${C2}$INDIR${CR}" echo " Output Location: ${C2}$OUTDIR${CR}" echo "" echo " Input ATMOS Resolution: ${C2}$IM_OLD $JM_OLD${CR}" echo " Input OCEAN Resolution: ${C2}$SST_IMI $SST_JMI${CR}" echo " Input BC Tag: ${C2}$BCTAGI${CR}" echo " Input TILE File: ${C2}$TILE_OLD${CR}" echo "" echo " Output ATMOS Resolution: ${C2}$IM_NEW $JM_NEW${CR}" echo " Output OCEAN Resolution: ${C2}$SST_IMO $SST_JMO${CR}" echo " Output BC Tag: ${C2}$BCTAGO${CR}" echo " Output TILE File: ${C2}$TILE_NEW${CR}" echo "" echo " Input Date: ${C2}$nymd${CR}" echo " Input Time: ${C2}$nhms${CR}" echo "" echo "regrid command line:" echo "--------------------" set command_line = "regrid -in $INDIR " if( $nymd != NULL ) set command_line = `echo $command_line -nymd $nymd ` if( $nhms != NULL ) set command_line = `echo $command_line -nhms $nhms ` set command_line = `echo $command_line -bctagi $BCTAGI ` set command_line = `echo $command_line -tilei $TILE_OLD ` set command_line = `echo $command_line -oceani $OCEANI ` set command_line = `echo $command_line -out $OUTDIR ` set command_line = `echo $command_line -bctago $BCTAGO ` set command_line = `echo $command_line -tileo $TILE_NEW ` set command_line = `echo $command_line -oceano $OCEANO ` set command_line = `echo $command_line -im $IM_NEW ` set command_line = `echo $command_line -jm $JM_NEW ` echo $command_line echo ""