1616
1717using namespace std ;
1818
19- enum { merge, invert, preserve };
19+ enum { mergeOp, invertOp, preserveOp };
2020
2121int nCells, nVertices, nEdges, vertexDegree, maxEdges;
2222bool spherical, periodic;
@@ -155,13 +155,13 @@ int main ( int argc, char *argv[] ) {
155155 for ( int i = 3 ; i < argc; i+=2 ) {
156156 foundOperation = false ;
157157 if (strcmp (argv[i], " -m" ) == 0 ) {
158- mask_ops.push_back (static_cast <int >(merge ));
158+ mask_ops.push_back (static_cast <int >(mergeOp ));
159159 foundOperation = true ;
160160 } else if ( strcmp (argv[i], " -i" ) == 0 ){
161- mask_ops.push_back (static_cast <int >(invert ));
161+ mask_ops.push_back (static_cast <int >(invertOp ));
162162 foundOperation = true ;
163163 } else if ( strcmp (argv[i], " -p" ) == 0 ){
164- mask_ops.push_back (static_cast <int >(preserve ));
164+ mask_ops.push_back (static_cast <int >(preserveOp ));
165165 foundOperation = true ;
166166 } else if ( strcmp (argv[i], " -c" ) == 0 ){
167167 outputMap = true ;
@@ -471,8 +471,8 @@ int mergeCellMasks(const string masksFilename, const int maskOp){/*{{{*/
471471 }
472472 }
473473
474- if ( maskOp == invert || maskOp == merge ) {
475- if ( maskOp == invert ) {
474+ if ( maskOp == invertOp || maskOp == mergeOp ) {
475+ if ( maskOp == invertOp ) {
476476 for (i = 0 ; i < nCells; i++){
477477 flattenedMask[i] = (flattenedMask[i] + 1 ) % 2 ;
478478 }
@@ -481,7 +481,7 @@ int mergeCellMasks(const string masksFilename, const int maskOp){/*{{{*/
481481 for ( i = 0 ; i < nCells; i++ ){
482482 cullCell[i] = max (cullCell[i], flattenedMask[i]);
483483 }
484- } else if ( maskOp == preserve ) {
484+ } else if ( maskOp == preserveOp ) {
485485 for ( i = 0 ; i < nCells; i++ ) {
486486 if ( flattenedMask[i] && cullCell[i] ) {
487487 cullCell[i] = 0 ;
@@ -614,21 +614,21 @@ int outputGridDimensions( const string outputFilename ){/*{{{*/
614614 int nCellsNew, nEdgesNew, nVerticesNew;
615615 // Return this code to the OS in case of failure.
616616 static const int NC_ERR = 2 ;
617-
617+
618618 // set error behaviour (matches fortran behaviour)
619619 NcError err (NcError::verbose_nonfatal);
620-
620+
621621 // open the scvtmesh file
622622 NcFile grid (outputFilename.c_str (), NcFile::Replace, NULL , 0 , NcFile::Offset64Bits);
623623
624624 /*
625625 for(vec_int_itr = edgesOnCell.begin(); vec_int_itr != edgesOnCell.end(); ++vec_int_itr){
626- maxEdges = std::max(maxEdges, (int)(*vec_int_itr).size());
626+ maxEdges = std::max(maxEdges, (int)(*vec_int_itr).size());
627627 }*/
628-
628+
629629 // check to see if the file was opened
630630 if (!grid.is_valid ()) return NC_ERR;
631-
631+
632632 // define dimensions
633633 NcDim *nCellsDim;
634634 NcDim *nEdgesDim;
@@ -652,7 +652,7 @@ int outputGridDimensions( const string outputFilename ){/*{{{*/
652652 for (int iEdge = 0 ; iEdge < nEdges; iEdge++){
653653 nEdgesNew += (edgeMap.at (iEdge) != -1 );
654654 }
655-
655+
656656 // write dimensions
657657 if (!(nCellsDim = grid.add_dim ( " nCells" , nCellsNew) )) return NC_ERR;
658658 if (!(nEdgesDim = grid.add_dim ( " nEdges" , nEdgesNew) )) return NC_ERR;
@@ -662,7 +662,7 @@ int outputGridDimensions( const string outputFilename ){/*{{{*/
662662 if (!(timeDim = grid.add_dim ( " Time" ) )) return NC_ERR;
663663
664664 grid.close ();
665-
665+
666666 // file closed when file obj goes out of scope
667667 return 0 ;
668668}/* }}}*/
@@ -675,10 +675,10 @@ int outputGridAttributes( const string inputFilename, const string outputFilenam
675675 * **********************************************************************/
676676 // Return this code to the OS in case of failure.
677677 static const int NC_ERR = 2 ;
678-
678+
679679 // set error behaviour (matches fortran behaviour)
680680 NcError err (NcError::verbose_nonfatal);
681-
681+
682682 // open the scvtmesh file
683683 NcFile grid (outputFilename.c_str (), NcFile::Write);
684684
@@ -689,7 +689,7 @@ int outputGridAttributes( const string inputFilename, const string outputFilenam
689689 string history_str = " " ;
690690 string id_str = " " ;
691691 string parent_str = " " ;
692-
692+
693693 // write attributes
694694 if (!spherical){
695695 if (!(sphereAtt = grid.add_att ( " on_a_sphere" , " NO\0 " ))) return NC_ERR;
@@ -734,7 +734,7 @@ int outputGridAttributes( const string inputFilename, const string outputFilenam
734734 if (!(id = grid.add_att ( " file_id" , id_str.c_str () ))) return NC_ERR;
735735
736736 grid.close ();
737-
737+
738738 // file closed when file obj goes out of scope
739739 return 0 ;
740740}/* }}}*/
@@ -749,16 +749,16 @@ int mapAndOutputGridCoordinates( const string inputFilename, const string output
749749 * **********************************************************************/
750750 // Return this code to the OS in case of failure.
751751 static const int NC_ERR = 2 ;
752-
752+
753753 // set error behaviour (matches fortran behaviour)
754754 NcError err (NcError::verbose_nonfatal);
755-
755+
756756 // open the scvtmesh file
757757 NcFile grid (outputFilename.c_str (), NcFile::Write);
758-
758+
759759 // check to see if the file was opened
760760 if (!grid.is_valid ()) return NC_ERR;
761-
761+
762762 // fetch dimensions
763763 NcDim *nCellsDim = grid.get_dim ( " nCells" );
764764 NcDim *nEdgesDim = grid.get_dim ( " nEdges" );
@@ -774,7 +774,7 @@ int mapAndOutputGridCoordinates( const string inputFilename, const string output
774774 NcVar *idx2cellVar, *idx2edgeVar, *idx2vertexVar;
775775
776776 int i, idx_map;
777-
777+
778778 double *xOld, *yOld, *zOld, *latOld, *lonOld;
779779 double *xNew, *yNew, *zNew, *latNew, *lonNew;
780780 int *idxToNew;
@@ -833,7 +833,7 @@ int mapAndOutputGridCoordinates( const string inputFilename, const string output
833833 delete[] latNew;
834834 delete[] lonNew;
835835 delete[] idxToNew;
836-
836+
837837 // Build and write edge coordinate arrays
838838 xOld = new double [nEdges];
839839 yOld = new double [nEdges];
@@ -964,16 +964,16 @@ int mapAndOutputCellFields( const string inputFilename, const string outputFilen
964964 * ***************************************************************/
965965 // Return this code to the OS in case of failure.
966966 static const int NC_ERR = 2 ;
967-
967+
968968 // set error behaviour (matches fortran behaviour)
969969 NcError err (NcError::verbose_nonfatal);
970-
970+
971971 // open the scvtmesh file
972972 NcFile grid (outputFilename.c_str (), NcFile::Write);
973-
973+
974974 // check to see if the file was opened
975975 if (!grid.is_valid ()) return NC_ERR;
976-
976+
977977 // fetch dimensions
978978 NcDim *nCellsDim = grid.get_dim ( " nCells" );
979979 NcDim *nEdgesDim = grid.get_dim ( " nEdges" );
@@ -993,7 +993,7 @@ int mapAndOutputCellFields( const string inputFilename, const string outputFilen
993993 double *areaCellNew;
994994 int *tmp_arr_old, *nEdgesOnCellOld, *nEdgesOnCellNew;
995995 int *tmp_arr_new;
996-
996+
997997 tmp_arr_old = new int [nCells*maxEdges];
998998 nEdgesOnCellOld = new int [nCells];
999999 nEdgesOnCellNew = new int [nCellsNew];
@@ -1106,7 +1106,7 @@ int mapAndOutputCellFields( const string inputFilename, const string outputFilen
11061106 delete[] tmp_arr_new;
11071107
11081108 // Map areaCell
1109- areaCellNew = new double [nCellsNew];
1109+ areaCellNew = new double [nCellsNew];
11101110
11111111 for (int iCell = 0 ; iCell < nCells; iCell++){
11121112 if (cellMap.at (iCell) != -1 ){
@@ -1154,16 +1154,16 @@ int mapAndOutputEdgeFields( const string inputFilename, const string outputFilen
11541154 * ***************************************************************/
11551155 // Return this code to the OS in case of failure.
11561156 static const int NC_ERR = 2 ;
1157-
1157+
11581158 // set error behaviour (matches fortran behaviour)
11591159 NcError err (NcError::verbose_nonfatal);
1160-
1160+
11611161 // open the scvtmesh file
11621162 NcFile grid (outputFilename.c_str (), NcFile::Write);
1163-
1163+
11641164 // check to see if the file was opened
11651165 if (!grid.is_valid ()) return NC_ERR;
1166-
1166+
11671167 // fetch dimensions
11681168 NcDim *nEdgesDim = grid.get_dim ( " nEdges" );
11691169 NcDim *maxEdges2Dim = grid.get_dim ( " maxEdges2" );
@@ -1265,7 +1265,7 @@ int mapAndOutputEdgeFields( const string inputFilename, const string outputFilen
12651265#endif
12661266 }
12671267 }
1268-
1268+
12691269 if (!(voeVar = grid.add_var (" verticesOnEdge" , ncInt, nEdgesDim, twoDim))) return NC_ERR;
12701270 if (!voeVar->put (verticesOnEdgeNew,nEdgesNew,2 )) return NC_ERR;
12711271 if (!(coeVar = grid.add_var (" cellsOnEdge" , ncInt, nEdgesDim, twoDim))) return NC_ERR;
@@ -1394,16 +1394,16 @@ int mapAndOutputVertexFields( const string inputFilename, const string outputFil
13941394 * ***************************************************************/
13951395 // Return this code to the OS in case of failure.
13961396 static const int NC_ERR = 2 ;
1397-
1397+
13981398 // set error behaviour (matches fortran behaviour)
13991399 NcError err (NcError::verbose_nonfatal);
1400-
1400+
14011401 // open the scvtmesh file
14021402 NcFile grid (outputFilename.c_str (), NcFile::Write);
1403-
1403+
14041404 // check to see if the file was opened
14051405 if (!grid.is_valid ()) return NC_ERR;
1406-
1406+
14071407 // fetch dimensions
14081408 NcDim *nVerticesDim = grid.get_dim ( " nVertices" );
14091409 NcDim *vertexDegreeDim = grid.get_dim ( " vertexDegree" );
0 commit comments