# Failure to create oceanfile

**URL:** <https://forum.cmascenter.org/t/failure-to-create-oceanfile/628>\
**Category:** Spatial Allocator\
**Created:** [April 24, 2019, 3:52pm UTC](https://forum.cmascenter.org/t/failure-to-create-oceanfile/628 "2019-04-24T15:52:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaofen](https://avatars.discourse-cdn.com/v4/letter/x/e79b87/32.png) [@xiaofen](https://forum.cmascenter.org/u/xiaofen)\
**Post date:** [April 24, 2019, 3:52pm UTC](https://forum.cmascenter.org/t/failure-to-create-oceanfile/628/1 "2019-04-24T15:52:05Z")

</div>

Hi~

I am using spatial allocator to create ocean file for CMAQ. The domain is out of North America, so I made the shape files myself and import them to Spatial Allocator. However Spatial Allocator stopped without any error information. Here is my log file

WARNING: Environment variable: MAX\_INPUT\_FILE\_SHAPES, not set  
WARNING: Environment variable: OVERLAY\_TYPE, not set  
WARNING: Environment variable: MAX\_LINE\_SEG, not set  
WARNING: Environment variable: MAX\_LINE\_SEG, not set  
WARNING: polyIsect: There is no intersection between the sets of polygons  
WARNING: Possible empty intersection in data polygons  
Spatial Allocator Version 3.6, 03/10/2009

EV: MIMS\_PROCESSING=ALLOCATE  
EV: ALLOCATE\_ATTRS=TYPE  
EV: OUTPUT\_FILE\_NAME=/home/xiao/Build\_WRF/Spatial-Allocator/output/ocean\_file\_Grid-days20.ncf  
Using ALLOCATE mode  
EV: OUTPUT\_FILE\_TYPE=IoapiFile  
EV: OUTPUT\_FILE\_TYPE=IoapiFile  
EV: OUTPUT\_FILE\_TYPE=IoapiFile  
Reading Regular Grid

EV: OUTPUT\_GRID\_NAME=Grid-days20  
MAX\_LINE\_SEG not set, discretization intervals disabled  
griddesc file name = /home/xiao/Build\_WRF/Spatial-Allocator/data/GRIDDESC

Ellipsoid var = OUTPUT\_FILE\_ELLIPSOID  
EV: OUTPUT\_FILE\_ELLIPSOID=+a=6370997.0,+b=6370997.0  
Ellipsoid=+a=6370997.0,+b=6370997.0  
EV: OUTPUT\_GRID\_NAME=Grid-days20  
Not using BB optimization

Finished reading the output file…

EV: INPUT\_FILE\_TYPE=ShapeFile  
EV: INPUT\_FILE\_ELLIPSOID=+a=6370997.0,+b=6370997.0  
Ellipsoid=+a=6370997.0,+b=6370997.0  
EV: INPUT\_FILE\_MAP\_PRJN=+proj=lcc,+lat\_1=30,+lat\_2=60,+lat\_0=40,+lon\_0=112  
EV: INPUT\_FILE\_TYPE=ShapeFile  
EV: INPUT\_FILE\_NAME=/home/xiao/Build\_WRF/Spatial-Allocator/data/surfzone/ChinaMapCoast  
MAX\_LINE\_SEG not set, discretization intervals disabled  
max\_line\_seg=

Reading Shapefile /home/xiao/Build\_WRF/Spatial-Allocator/data/surfzone/ChinaMapCoast  
Shapefile Type: 5 Polygon # of Shapes: 44

Input projection:

args[1]=+a=6370997.0

args[2]=+b=6370997.0

param 0 = +proj=lcc,  
param 3 = +lat\_1=30,  
param 4 = +lat\_2=60,  
param 5 = +lat\_0=40,  
param 6 = +lon\_0=112,  
PROJ args=+proj=lcc+a=6370997.0+b=6370997.0+lat\_1=30+lat\_2=60+lat\_0=40+lon\_0=112

Output projection:

args[1]=+a=6370997.0

args[2]=+b=6370997.0

setting Lambert Conic Conformal – 2SP parameters  
PROJ args=+proj=lcc+a=6370997.0+b=6370997.0+lat\_1=30.000000+lat\_2=60.000000+lon\_0=112.000000+lat\_0=40.000000+units=m

Total area = 9.9707e+12

Skipped 0 polygons and 0 vertices

File bounding box:  
xmin = 16204787.444 xmax = 21277082.714 ymin = 2009033.435 ymax = 6010188.757

Finished reading the input shape file…

EV: ALLOCATE\_ATTRS=TYPE  
EV: ALLOCATE\_ATTRS=TYPE  
Not using function for weights

Using attribute TYPE

Finished reading the input attribute file…

xmin = 16204787.444 xmax = 21277082.714 ymin = 2009033.435 ymax = 6010188.757

xmin = -789000.000 xmax = 1367000.000 ymin = -2165500.000 ymax = -9500.000

0.0u 0.0s 0:00.15 46.6% 0+0k 0+8io 0pf+0w

Does anyone know the reason? Thank you in advance!

---

<div class="post-metadata">

**Author:** ![lizadams](https://avatars.discourse-cdn.com/v4/letter/l/49beb7/32.png) [@lizadams](https://forum.cmascenter.org/u/lizadams)\
**Post date:** [April 24, 2019, 4:16pm UTC](https://forum.cmascenter.org/t/failure-to-create-oceanfile/628/2 "2019-04-24T16:16:21Z")

</div>

If the spatial allocator script is set up to write the OUTPUT to a directory, and that directory doesn’t exist, then the spatial allocator will fail to create the output file. Please add a check to the script that if the directory doesn’t exist to make it prior to the run.

setenv OUTDIR $cwd/output

if ( ! -d “$OUTDIR” ) mkdir -p $OUTDIR

---

<div class="post-metadata">

**Author:** ![xiaofen](https://avatars.discourse-cdn.com/v4/letter/x/e79b87/32.png) [@xiaofen](https://forum.cmascenter.org/u/xiaofen)\
**Post date:** [April 25, 2019, 7:36am UTC](https://forum.cmascenter.org/t/failure-to-create-oceanfile/628/3 "2019-04-25T07:36:28Z")

</div>

Hi Liz,

Thanks for your reply! I wrote the code to the script. However the log file does not change. Here is my ‘alloc\_surf\_zone\_to\_oceanfile\_China.csh’ script

cd /home/xiao/Build\_WRF/Spatial-Allocator/bin  
source sa\_setup.csh  
cd …/scripts

setenv DEBUG\_OUTPUT Y

# Set executable

setenv EXE “$SA\_HOME/bin/64bits/allocator.exe”

# Set Input Directory

setenv DATADIR $SA\_HOME/data  
setenv OUTPUT $SA\_HOME/output

if ( ! -d “$OUTPUT” ) mkdir -p $OUTPUT

# Select method of spatial analysis

setenv MIMS\_PROCESSING ALLOCATE

setenv TIME time

#set “data” shapefile parameters  
setenv GRIDDESC $DATADIR/GRIDDESC

#set parameters for file being allocated  
setenv INPUT\_FILE\_NAME $DATADIR/surfzone/ChinaMapCoast  
setenv INPUT\_FILE\_TYPE ShapeFile  
setenv INPUT\_FILE\_MAP\_PRJN “+proj=lcc,+lat\_1=30,+lat\_2=60,+lat\_0=40,+lon\_0=112”  
setenv INPUT\_FILE\_ELLIPSOID “+a=6370997.0,+b=6370997.0”  
setenv ALLOCATE\_ATTRS TYPE  
setenv ALLOC\_MODE\_FILE ALL\_AREAPERCENT

#Set this to SURF\_ZONE to create the variables needed for CMAQ OCEANfile  
setenv ALLOC\_ATTR\_TYPE SURF\_ZONE

# Set name and path of resulting shapefile

setenv OUTPUT\_FILE\_TYPE IoapiFile  
setenv OUTPUT\_GRID\_NAME Grid-days20  
setenv OUTPUT\_FILE\_MAP\_PRJN “+proj=lcc,+lat\_1=30,+lat\_2=60,+lat\_0=40,+lon\_0=112”  
setenv OUTPUT\_FILE\_ELLIPSOID “+a=6370997.0,+b=6370997.0”  
setenv OUTPUT\_FILE\_NAME $OUTPUT/ocean\_file.ncf

#echo “Allocating surf zone data to CMAQ OCEANfile”  
$TIME $EXE

I guess I have the output directory. Could you please take a look at it? Thanks!

---

<div class="post-metadata">

**Author:** ![dyang](https://avatars.discourse-cdn.com/v4/letter/d/dbc845/32.png) [@dyang](https://forum.cmascenter.org/u/dyang)\
**Post date:** [April 25, 2019, 1:23pm UTC](https://forum.cmascenter.org/t/failure-to-create-oceanfile/628/4 "2019-04-25T13:23:08Z")

</div>

> [@xiaofen](#):
>
> WARNING: polyIsect: There is no intersection between the sets of polygons  
> WARNING: Possible empty intersection in data polygons

From the warning message, it means that your ocean surfzone shape file doesn’t intersect with your grid domain. Please double check if the projection your shape file used is same as what you specified in script. Also check your GRIDDESC on the projection used for Grid-days20. If possible, your can do some QA using ArcGIS.

---

<div class="post-metadata">

**Author:** ![xiaofen](https://avatars.discourse-cdn.com/v4/letter/x/e79b87/32.png) [@xiaofen](https://forum.cmascenter.org/u/xiaofen)\
**Post date:** [April 25, 2019, 3:15pm UTC](https://forum.cmascenter.org/t/failure-to-create-oceanfile/628/5 "2019-04-25T15:15:57Z")

</div>

Hi Yang,

Thanks! And you are right. The projections of the shapefile and GRIDDESC are not aligned. I correct the projection of the shapefile with QGIS. Now everything goes well.
