Ignore:
Timestamp:
04/25/18 17:30:25 (3 years ago)
Author:
oabramkina
Message:

Bigfix for UGRID: fields describing the same mesh (= fields defined on domains with the same name) are sorted in the decreasing order of nvertex. The first, and the only, domain to be written is that with the highest value of nvertex. The entire mesh connectivity will be generated according to this domain.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/nc4_data_output.cpp

    r1459 r1494  
    557557 
    558558      if (domain->IsWritten(this->filename)) return; 
     559 
     560      StdString domid = domain->getDomainOutputName(); 
     561 
     562      // The first domain for the same mesh that will be written is that with the highest value of nvertex. 
     563      // Thus the entire mesh connectivity will be generated at once. 
     564      if (isWrittenDomain(domid)) return ; 
     565      else setWrittenDomain(domid); 
     566 
    559567      domain->checkAttributes(); 
    560568      if (domain->isEmpty()) 
     
    567575 
    568576      std::vector<StdString> dim0; 
    569       StdString domid = domain->getDomainOutputName(); 
    570577      StdString domainName = domain->name; 
    571578      domain->assignMesh(domainName, domain->nvertex); 
     
    593600 
    594601      if (!SuperClassWriter::dimExist(dimTwo)) SuperClassWriter::addDimension(dimTwo, 2); 
    595       if (!isWrittenDomain(domid)) 
    596       { 
    597         dim0.clear(); 
    598         SuperClassWriter::addVariable(domainName, NC_INT, dim0, compressionLevel); 
    599         SuperClassWriter::addAttribute("cf_role", StdString("mesh_topology"), &domainName); 
    600         SuperClassWriter::addAttribute("long_name", StdString("Topology data of 2D unstructured mesh"), &domainName); 
    601         SuperClassWriter::addAttribute("topology_dimension", 2, &domainName); 
    602         SuperClassWriter::addAttribute("node_coordinates", node_x + " " + node_y, &domainName); 
    603       } 
     602      dim0.clear(); 
     603      SuperClassWriter::addVariable(domainName, NC_INT, dim0, compressionLevel); 
     604      SuperClassWriter::addAttribute("cf_role", StdString("mesh_topology"), &domainName); 
     605      SuperClassWriter::addAttribute("long_name", StdString("Topology data of 2D unstructured mesh"), &domainName); 
     606      SuperClassWriter::addAttribute("topology_dimension", 2, &domainName); 
     607      SuperClassWriter::addAttribute("node_coordinates", node_x + " " + node_y, &domainName); 
    604608 
    605609      try 
     
    773777            std::vector<StdSize> countFaceConctv(2) ; 
    774778 
    775             if (!isWrittenDomain(domid)) 
     779            if (domain->nvertex == 1) 
    776780            { 
    777               if (domain->nvertex == 1) 
    778               { 
    779                 if (domain->isEmpty()) 
    780                  { 
    781                    startNodes[0]=0 ; 
    782                    countNodes[0]=0 ; 
    783                  } 
    784                  else 
    785                  { 
    786                    startNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
    787                    countNodes[0] = domain->zoom_ni ; 
    788                  } 
    789  
    790                 SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); 
    791                 SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); 
    792               } 
    793               else if (domain->nvertex == 2) 
    794               { 
    795                 if (domain->isEmpty()) 
    796                  { 
    797                   startEdges[0]=0 ; 
    798                   countEdges[0]=0 ; 
    799                   startNodes[0]=0 ; 
    800                   countNodes[0]=0 ; 
    801                   startEdgeNodes[0]=0; 
    802                   startEdgeNodes[1]=0; 
    803                   countEdgeNodes[0]=0; 
    804                   countEdgeNodes[1]=0; 
    805  
    806                  } 
    807                  else 
    808                  { 
    809                    startEdges[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
    810                    countEdges[0] = domain->zoom_ni; 
    811                    startNodes[0] = domain->mesh->node_start; 
    812                    countNodes[0] = domain->mesh->node_count; 
    813                    startEdgeNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
    814                    startEdgeNodes[1] = 0; 
    815                    countEdgeNodes[0] = domain->zoom_ni; 
    816                    countEdgeNodes[1] = 2; 
    817                  } 
    818                 SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); 
    819                 SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); 
    820                 SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); 
    821                 SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); 
    822                 SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); 
    823               } 
    824               else 
    825               { 
    826                 if (domain->isEmpty()) 
    827                  { 
    828                    startFaces[0] = 0 ; 
    829                    countFaces[0] = 0 ; 
    830                    startNodes[0] = 0; 
    831                    countNodes[0] = 0; 
    832                    startEdges[0] = 0; 
    833                    countEdges[0] = 0; 
    834                    startEdgeFaces[0] = 0; 
    835                    startEdgeFaces[1] = 0; 
    836                    countEdgeFaces[0] = 0; 
    837                    countEdgeFaces[1] = 0; 
    838                    startFaceConctv[0] = 0; 
    839                    startFaceConctv[1] = 0; 
    840                    countFaceConctv[0] = 0; 
    841                    countFaceConctv[1] = 0; 
    842                  } 
    843                  else 
    844                  { 
    845                    startFaces[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
    846                    countFaces[0] = domain->zoom_ni ; 
    847                    startNodes[0] = domain->mesh->node_start; 
    848                    countNodes[0] = domain->mesh->node_count; 
    849                    startEdges[0] = domain->mesh->edge_start; 
    850                    countEdges[0] = domain->mesh->edge_count; 
    851                    startEdgeNodes[0] = domain->mesh->edge_start; 
    852                    startEdgeNodes[1] = 0; 
    853                    countEdgeNodes[0] = domain->mesh->edge_count; 
    854                    countEdgeNodes[1]= 2; 
    855                    startEdgeFaces[0] = domain->mesh->edge_start; 
    856                    startEdgeFaces[1]= 0; 
    857                    countEdgeFaces[0] = domain->mesh->edge_count; 
    858                    countEdgeFaces[1]= 2; 
    859                    startFaceConctv[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
    860                    startFaceConctv[1] = 0;  
    861                    countFaceConctv[0] = domain->zoom_ni; 
    862                    countFaceConctv[1] = domain->nvertex; 
    863                  } 
    864                 SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); 
    865                 SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); 
    866                 SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); 
    867                 SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); 
    868                 SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); 
    869                 SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0, &startFaces, &countFaces); 
    870                 SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0, &startFaces, &countFaces); 
    871                 SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes, isCollective, 0, &startFaceConctv, &countFaceConctv); 
    872                 SuperClassWriter::writeData(domain->mesh->face_edges, face_edges, isCollective, 0, &startFaceConctv, &countFaceConctv); 
    873                 SuperClassWriter::writeData(domain->mesh->edge_faces, edge_faces, isCollective, 0, &startEdgeFaces, &countEdgeFaces); 
    874                 SuperClassWriter::writeData(domain->mesh->face_faces, face_faces, isCollective, 0, &startFaceConctv, &countFaceConctv); 
    875               } 
    876               setWrittenDomain(domid); 
    877             } // !isWrittenDomain 
     781              if (domain->isEmpty()) 
     782               { 
     783                 startNodes[0]=0 ; 
     784                 countNodes[0]=0 ; 
     785               } 
     786               else 
     787               { 
     788                 startNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
     789                 countNodes[0] = domain->zoom_ni ; 
     790               } 
     791 
     792              SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); 
     793              SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); 
     794            } 
     795            else if (domain->nvertex == 2) 
     796            { 
     797              if (domain->isEmpty()) 
     798               { 
     799                startEdges[0]=0 ; 
     800                countEdges[0]=0 ; 
     801                startNodes[0]=0 ; 
     802                countNodes[0]=0 ; 
     803                startEdgeNodes[0]=0; 
     804                startEdgeNodes[1]=0; 
     805                countEdgeNodes[0]=0; 
     806                countEdgeNodes[1]=0; 
     807 
     808               } 
     809               else 
     810               { 
     811                 startEdges[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
     812                 countEdges[0] = domain->zoom_ni; 
     813                 startNodes[0] = domain->mesh->node_start; 
     814                 countNodes[0] = domain->mesh->node_count; 
     815                 startEdgeNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
     816                 startEdgeNodes[1] = 0; 
     817                 countEdgeNodes[0] = domain->zoom_ni; 
     818                 countEdgeNodes[1] = 2; 
     819               } 
     820              SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); 
     821              SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); 
     822              SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); 
     823              SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); 
     824              SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); 
     825            } 
    878826            else 
    879827            { 
    880               if (domain->nvertex == 2) 
    881               { 
    882                 startEdges[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
    883                 countEdges[0] = domain->zoom_ni; 
    884                 startEdgeNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
    885                 startEdgeNodes[1] = 0; 
    886                 countEdgeNodes[0] = domain->zoom_ni; 
    887                 countEdgeNodes[1]= 2; 
    888                 SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); 
    889                 SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); 
    890                 SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); 
    891               }   
    892               if (domain->nvertex > 2) 
    893               { 
    894  
    895                 if (!domain->mesh->edgesAreWritten) 
    896                 { 
    897                   startEdges[0] = domain->mesh->edge_start; 
    898                   countEdges[0] = domain->mesh->edge_count; 
    899                   startEdgeNodes[0] = domain->mesh->edge_start; 
    900                   startEdgeNodes[1] = 0; 
    901                   countEdgeNodes[0] = domain->mesh->edge_count; 
    902                   countEdgeNodes[1]= 2; 
    903                   SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); 
    904                   SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); 
    905                   SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); 
    906                 } 
    907                 startFaces[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
    908                 countFaces[0] = domain->zoom_ni; 
    909                 startEdgeFaces[0] = domain->mesh->edge_start; 
    910                 startEdgeFaces[1]= 0; 
    911                 countEdgeFaces[0] = domain->mesh->edge_count; 
    912                 countEdgeFaces[1]= 2; 
    913                 startFaceConctv[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
    914                 startFaceConctv[1] = 0; 
    915                 countFaceConctv[0] = domain->zoom_ni; 
    916                 countFaceConctv[1] = domain->nvertex; 
    917                 SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0, &startFaces, &countFaces); 
    918                 SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0, &startFaces, &countFaces); 
    919                 SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes, isCollective, 0, &startFaceConctv, &countFaceConctv); 
    920                 SuperClassWriter::writeData(domain->mesh->face_edges, face_edges, isCollective, 0, &startFaceConctv, &countFaceConctv); 
    921                 SuperClassWriter::writeData(domain->mesh->edge_faces, edge_faces, isCollective, 0, &startEdgeFaces, &countEdgeFaces); 
    922                 SuperClassWriter::writeData(domain->mesh->face_faces, face_faces, isCollective, 0, &startFaceConctv, &countFaceConctv); 
    923               } 
    924             }// isWrittenDomain 
    925  
     828              if (domain->isEmpty()) 
     829               { 
     830                 startFaces[0] = 0 ; 
     831                 countFaces[0] = 0 ; 
     832                 startNodes[0] = 0; 
     833                 countNodes[0] = 0; 
     834                 startEdges[0] = 0; 
     835                 countEdges[0] = 0; 
     836                 startEdgeFaces[0] = 0; 
     837                 startEdgeFaces[1] = 0; 
     838                 countEdgeFaces[0] = 0; 
     839                 countEdgeFaces[1] = 0; 
     840                 startFaceConctv[0] = 0; 
     841                 startFaceConctv[1] = 0; 
     842                 countFaceConctv[0] = 0; 
     843                 countFaceConctv[1] = 0; 
     844               } 
     845               else 
     846               { 
     847                 startFaces[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
     848                 countFaces[0] = domain->zoom_ni ; 
     849                 startNodes[0] = domain->mesh->node_start; 
     850                 countNodes[0] = domain->mesh->node_count; 
     851                 startEdges[0] = domain->mesh->edge_start; 
     852                 countEdges[0] = domain->mesh->edge_count; 
     853                 startEdgeNodes[0] = domain->mesh->edge_start; 
     854                 startEdgeNodes[1] = 0; 
     855                 countEdgeNodes[0] = domain->mesh->edge_count; 
     856                 countEdgeNodes[1]= 2; 
     857                 startEdgeFaces[0] = domain->mesh->edge_start; 
     858                 startEdgeFaces[1]= 0; 
     859                 countEdgeFaces[0] = domain->mesh->edge_count; 
     860                 countEdgeFaces[1]= 2; 
     861                 startFaceConctv[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; 
     862                 startFaceConctv[1] = 0; 
     863                 countFaceConctv[0] = domain->zoom_ni; 
     864                 countFaceConctv[1] = domain->nvertex; 
     865               } 
     866              SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); 
     867              SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); 
     868              SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); 
     869              SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); 
     870              SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); 
     871              SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0, &startFaces, &countFaces); 
     872              SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0, &startFaces, &countFaces); 
     873              SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes, isCollective, 0, &startFaceConctv, &countFaceConctv); 
     874              SuperClassWriter::writeData(domain->mesh->face_edges, face_edges, isCollective, 0, &startFaceConctv, &countFaceConctv); 
     875              SuperClassWriter::writeData(domain->mesh->edge_faces, edge_faces, isCollective, 0, &startEdgeFaces, &countEdgeFaces); 
     876              SuperClassWriter::writeData(domain->mesh->face_faces, face_faces, isCollective, 0, &startFaceConctv, &countFaceConctv); 
     877            } 
    926878            SuperClassWriter::definition_start(); 
    927879 
Note: See TracChangeset for help on using the changeset viewer.