ESCOMP / CTSM

Community Terrestrial Systems Model (includes the Community Land Model of CESM)
http://www.cesm.ucar.edu/models/cesm2.0/land/
Other
309 stars 313 forks source link

Add ability to send GRIDFILE to regridbatch.sh script #474

Closed ekluzek closed 5 years ago

ekluzek commented 6 years ago

This is especially needed for NWP. We need to add the ability to not only send the resolution to run at through the RES env variable, but also the SCIRP grid file to use through a variable called GRIDFILE. This way you could run mkmapdata.sh with

env MKMAPDATA= RES= qsub regridbatch.sh

@barlage

ekluzek commented 6 years ago

Here's some changes to get this working...

--- a/tools/mkmapdata/regridbatch.sh
+++ b/tools/mkmapdata/regridbatch.sh
@@ -29,9 +29,23 @@
 if [ -z "$RES" ]; then
    echo "Run for all valid resolutions"
    resols=`../../bld/queryDefaultNamelist.pl -res list -silent`
+   if [ ! -z "$GRIDFILE" ]; then
+      echo "When GRIDFILE set RES also needs to be set for a single resolution"
+      exit 1
+   fi
 else
    resols="$RES"
 fi
+if [ -z "$GRIDFILE" ]; then
+  grid=""
+else
+   if [[ ${#resols[@]} > 1 ]]; then
+      echo "When GRIDFILE is specificed only one resolution can also be given (# resolutions ${#resols[@]})"
+      echo "Resolutions input is: $resols"
+      exit 1
+   fi
+   grid="-f $GRIDFILE"
+fi
 echo "Create mapping files for this list of resolutions: $resols"

 #----------------------------------------------------------------------
@@ -39,7 +53,7 @@ echo "Create mapping files for this list of resolutions: $resols"
 for res in $resols; do
    echo "Create mapping files for: $res"
 #----------------------------------------------------------------------
-   cmdargs="-r $res"
+   cmdargs="-r $res $grid"

    # For single-point and regional resolutions, tell mkmapdata that
    # output type is regional
@@ -48,6 +62,10 @@ for res in $resols; do
    else
        res_type="global"
    fi
+   # Assume if you are providing a gridfile that the grid is regional
+   if [ $grid != "" ];then
+       res_type="regional"
+   fi

    cmdargs="$cmdargs -t $res_type"
billsacks commented 5 years ago

This has been done.