Ejemplo n.º 1
0
static void f77name(save_openmp_state)()
{
  int ONE=1;

  omp_max_threads=f77name(f_omp_get_max_threads)();
  f77name(f_omp_set_num_threads)(&ONE);
/*
  printf("Saved state : %d CPUs\n",omp_max_threads);
  printf("Number of threads set to %d\n",ONE);
*/
}
Ejemplo n.º 2
0
void f77name(restore_openmp_state)()
{
  f77name(f_omp_set_num_threads)(&omp_max_threads);
/*
  printf("Number of threads set to %d\n",omp_max_threads);
*/
}
Ejemplo n.º 3
0
ftnword f77name(close_db_file)(ftnword *iun)                                    
{
  int ier, f, i;
 
  f = -1;
  for (i=0; i < Max_File; i++)
    if (TB[i].iun == *iun) {
      f = i;
      break;
    }
  if (f == -1) {
    fprintf(stderr,"close_db_file error: file (unit=%d) not open\n",*iun);
    exit(7);
  }

  ier = f77name(rewind_db_file)(iun);

  TB[f].fd = -1;
  TB[f].iun = -1;
  TB[f].pos_in = 0;
  TB[f].pos_out = 0;
  TB[f].nb_elmt_lu = 0;
  TB[f].nb_elmt_ecrit = 0;
  free(TB[f].pBuf_IN);
  free(TB[f].pBuf_OUT);
  TB[f].pBuf_IN = NULL;
  TB[f].pBuf_OUT = NULL;
  return(0);
}
Ejemplo n.º 4
0
void c_xy2fxfy(float *fx, float *fy, float x, float y)
{
  int ix;
  int iy;
  int un = 1;
  float x_x, y_y;

  x_x = x;
  y_y = y;

  switch (usSpace.mapping)
    {
    case 5:
    *fx = x;
    f77name(ez_rgdint_1_nw)(fy,&x_x,&y_y, &un, usSpace.z, &usSpace.ni,&un, &usSpace.nj);
    break;

    case 6:
    f77name(ez_rgdint_1_nw)(fx,&x_x,&y_y, &un, usSpace.zx, &usSpace.ni,&un, &usSpace.nj);
    f77name(ez_rgdint_1_nw)(fy,&x_x,&y_y, &un, usSpace.zy, &usSpace.ni,&un, &usSpace.nj);
    break;

    default:
    if (usSpace.axex)
      {
      INTERP(*fx, x, usSpace.axex, usSpace.ni)
      }
    else
      {
      *fx = x_x;
      }

    if (usSpace.axey)
      {
      INTERP(*fy, y_y, usSpace.axey, usSpace.nj)
      }
    else
      {
      *fy = y_y;
      }
     break;
    }




  }
Ejemplo n.º 5
0
Archivo: bozo.c Proyecto: guziy/rmnlib
ftnword f77name(bozo)(void *name, void *type, void *etik, void *grtyp,
                        char *cname, char *ctype, char *cetik, char *cgrtyp, void *holocar,
                        F2Cl l1, F2Cl l2, F2Cl l3, F2Cl l4)
{
  int ier;
 
  printf("fstcvt cname=%s,ctype=%s,cetik=%s,cgrtyp=%s\n",cname,ctype,cetik,cgrtyp);   
  ier = f77name(fstcvt2)(name,type,etik,grtyp,cname,ctype,cetik,cgrtyp,holocar,l1,l2,l3,l4);
  return((ftnword) ier);
}
Ejemplo n.º 6
0
/* sequence of operations

   PE 0                      PE 1            .......     PE last

   accept                    accept                      NO-OP
   NO-OP                     connect(PE 0)               connect(PE last-1)
   NO-OP                     read(PE 0)                  read(PE last-1)
   write(PE 1)               write(PE 2)                 NO-OP
   read(PE 1)                read(PE 2)                  NO-OP
   NO-OP                     write(PE 0)                 write(PE last-1)
   NO-OP                     close(PE 0)                 close(PE last-1)
   close(PE 1)               close(PE 2)                 NO-OP

*/
int f77name(rpn_comm_softbarrier)(ftnword *comm)   /* perform a soft sync */
{
  char buf[1024];
  int fdesc_up=-1, fdesc_down=-1;
  int status=-1;
  struct set_of_ports *p=chain;
  
  while ( (p!=NULL) && (p->comm != *comm) ) p = p->next ;
  if ( p == NULL ) return(-1);
  
  f77name(save_openmp_state)();
#ifdef DEBUG
  printf("Entering rpn_comm_soft_sync, PE=%d\n",p->pe_me);
  fflush(stdout);
  if(p->pe_me == 0) sleep(1);
#endif
  if(p->pe_me != p->nprocs-1) fdesc_down=accept_from_sock(p->my_server);
#ifdef DEBUG
  if(p->pe_me != p->nprocs-1) printf("PE=%d, accept_from_sock,fdesc_down=%d\n",p->pe_me,fdesc_down);
  fflush(stdout);
#endif
  if(p->pe_me != 0){
#ifdef DEBUG
    printf("PE=%d,connect_to_port %d@%x\n",p->pe_me,p->list_port[p->pe_me-1],p->list_server[p->pe_me-1]);
#endif
    fdesc_up=connect_to_port(p->list_server[p->pe_me-1],p->list_port[p->pe_me-1]);
#ifdef DEBUG
    printf("PE=%d,connected_to_port %d@%x, desc=%d\n",p->pe_me,p->list_port[p->pe_me-1],p->list_server[p->pe_me-1],fdesc_up);
#endif
    read(fdesc_up,buf,4);
    }
  if(p->pe_me != p->nprocs-1) write(fdesc_down,buf,4);

  if(p->pe_me != p->nprocs-1) read(fdesc_down,buf,4);
  if(p->pe_me != 0) write(fdesc_up,buf,4);

  if(fdesc_up != -1) close(fdesc_up);
  if(fdesc_down != -1) close(fdesc_down);
  f77name(restore_openmp_state)();
  return(MPI_SUCCESS);
}
Ejemplo n.º 7
0
/*<----------------------------------------------------------------------------------------->*/
void ActiverPanneauEdition()
{

   if (!peTopLevel)
      InitPanneauEdition();
   
   if (!XtIsRealized(peTopLevel))
      {
      XtRealizeWidget(peTopLevel);
      CheckColormap(peTopLevel);
      }

   f77name(xpaneact)();
   
   }
Ejemplo n.º 8
0
void xmlconvip(char xmlip1[], int ip1)
{
  float niveau;
  int kind, mode;
  int flag = 1;
  int i;
  int lip1;
  F2Cl l=32;

  mode = -1;
  lip1 = ip1;
  for (i = 0; i < 32; i++) xmlip1[i]='\0';

  f77name(convip)(&lip1, &niveau, &kind, &mode, xmlip1, &flag, l );
  xmlip1[31] = '\0';
  nettoyer(xmlip1);
  
}
Ejemplo n.º 9
0
void xmlconvdate(char xmldate[], int dateo)
{
  int ldateo, yyyymmdd, hhmmssss, mode;
  int yyyy, month, day, hour, minutes, sec, fracsec;
  
  mode = -3;
  ldateo = dateo;

  f77name(newdate)(&ldateo, &yyyymmdd, &hhmmssss, &mode);

  yyyy = yyyymmdd / 10000;
  month = (yyyymmdd / 100) % 100;
  day   = yyyymmdd % 100;

  hour = hhmmssss / 1000000;
  minutes = (hhmmssss / 10000) % 100;
  sec = (hhmmssss % 100);

  sprintf(xmldate, "%04d-%02d-%02dT%02d:%02d:%02dZ", yyyy, month, day, hour, minutes, sec);
}
Ejemplo n.º 10
0
void f77name(cmainieeedouble)()
{
  int i;

  FLOAT_4_8 arrayOfFloat0[myElementCount];
  FLOAT_4_8 arrayOfFloat[myElementCount2], arrayOfFloatTest[strideElementCount];
  FLOAT_4_8 arrayOfFloat1[myElementCount2], arrayOfFloat2[strideElementCount]; 
  FLOAT_4_8 arrayOfFloat3[myElementCount2], arrayOfFloat4[strideElementCount]; 
  FLOAT_4_8 arrayOfFloat5[myElementCount2], arrayOfFloat6[myElementCount2], arrayOfFloat7[myElementCount2];


  FLOAT_4_8 arrayOfFloat1_IEEE[myElementCount2], arrayOfFloat2_IEEE[myElementCount2];
  FLOAT_4_8 arrayOfFloat3_IEEE[myElementCount2];
  ftnword   ftnBitSizeOfIEEE, ftnBitSizeOfIBM, ftnElementCount, ftnCorrectElement, ftnErrorCode;



  word arrayOfInt1[myElementCount2], arrayOfInt2[myElementCount2];
  word arrayOfInt3[myElementCount2], arrayOfInt4[myElementCount2];
  word arrayOfInt5[myElementCount2], arrayOfInt6[myElementCount2], arrayOfInt7[myElementCount2];
  

  /***************************
    need to switch between 4 and 32 to check its viability
    *****************************/
  int bitSizeOfInt;
  int mBitSizeOfInt;
  int off_set = 1;
  int stride = 1;
  int opCode = FLOAT_PACK;
  int opCode1 = FLOAT_UNPACK; 
  ftnword *unpackedFloat1, *unpackedFloat2, *unpackedFloat3, *unpackedFloat4,*unpackedFloat5, *unpackedFloat6;

  FLOAT_4_8 missingTag = 9999.0000;
  FLOAT_4_8 tempFloat;
  FLOAT_4_8 maxError, maxDifference;
  int notStablized = 0;
  int strideNotWorking;
  int testError;
  int bitSizeOfExpo;
  int mantisaSize;
  int expoAlignment;
  FLOAT_4_8 powerOf2s[64];



  bitSizeOfInt  = okBit;
  mBitSizeOfInt = -okBit;






  powerOf2s[0] = 1.0;
  for ( i = 1; i < 64; i++)
    {
      powerOf2s[i] = 2.0 *powerOf2s[i-1];      
    };



  /*******************************************
   *                                         *
   *  transform IBM format into IEEE         *
   *                                         *
   ******************************************/
  ftnBitSizeOfIEEE = 4;
  ftnBitSizeOfIBM  = 4;
  ftnElementCount  = myElementCount2;
 





if ( geneticOn == 1 )
{
  /******************************
    genetic test
    ****************************/
  bitSizeOfInt = 16;
  bitSizeOfExpo = 7;
  mantisaSize = 9;

  printf("\n IEEE block test starts(double) \n" );  
  arrayOfFloat1[0] = 0.0;
  arrayOfFloat1[1] = 0.999999;

  for ( i = 2; i < elementCount ; i++ )
    {
      arrayOfFloat1[i] = ((i+1.0) / (elementCount + 10.0) - 0.5);
    };  
 

  f77name(fl1_ie3)(arrayOfFloat1, arrayOfFloat1_IEEE, &ftnBitSizeOfIBM, &ftnBitSizeOfIEEE, 
                   &ftnElementCount, &ftnCorrectElement, &ftnErrorCode);

  
  for ( bitSizeOfInt = 16; bitSizeOfInt < 33; bitSizeOfInt++)
    {

      if ( bitSizeOfInt < 21 )
        {
          bitSizeOfExpo = 5;
        }
      else if ( bitSizeOfInt < 25 )
        {
          bitSizeOfExpo = 6;
        }
      else if ( bitSizeOfInt < 29 )
        {
          bitSizeOfExpo = 7;
          
        }
      else 
        {
          bitSizeOfExpo = 8;
        }

      mantisaSize = bitSizeOfInt - bitSizeOfExpo - 1;
      expoAlignment = 126 - (powerOf2s[bitSizeOfExpo] - 1);



      unpackedFloat1 = compact_IEEEblock_FLOAT_4_8(arrayOfFloat1_IEEE, &arrayOfInt1[0], &arrayOfInt1[4], 
                                                   elementCount, bitSizeOfInt, 
                                                   bitSizeOfExpo, 0, 1, FLOAT_PACK, 0, &missingTag);
      
      unpackedFloat2 = compact_IEEEblock_FLOAT_4_8(arrayOfFloat2_IEEE, &arrayOfInt1[0], &arrayOfInt1[4], 
                                                   elementCount, bitSizeOfInt, 
                                                   bitSizeOfExpo, 0, 1, FLOAT_UNPACK, 0, &missingTag);

     
      f77name(ie3_fl1)(arrayOfFloat2_IEEE, arrayOfFloat2, &ftnBitSizeOfIEEE, &ftnBitSizeOfIBM, 
                       &ftnElementCount, &ftnCorrectElement, &ftnErrorCode);
     

      
      IEEEtransform(bitSizeOfInt, mantisaSize, expoAlignment, arrayOfFloat1_IEEE, arrayOfFloat3_IEEE, 
                     elementCount, stride); 

      f77name(ie3_fl1)(arrayOfFloat3_IEEE, arrayOfFloat3, &ftnBitSizeOfIEEE, &ftnBitSizeOfIBM, 
                       &ftnElementCount, &ftnCorrectElement, &ftnErrorCode);
                    



                                
  

      testError = 0;
      for ( i = 0; i < elementCount*stride; i+=stride)
        {
          if ( arrayOfFloat2[i] != arrayOfFloat3[i] )
            {
              testError = 1;
              printf("\t %d \t %f \t %f \n",  i, arrayOfFloat2[i], arrayOfFloat3[i]);
            }
        };

      if (testError == 1 )
        {
          printf(" bitSizeOfToken: %d \t bitSizeOfExpo: %d \t test not passed \n", 
                 bitSizeOfInt, bitSizeOfExpo);
        }
      else
        {
          printf(" bitSizeOfToken: %d \t bitSizeOfExpo: %d \t test passed \n", 
                 bitSizeOfInt, bitSizeOfExpo);
        };
    };

  bitSizeOfInt = 64;
  unpackedFloat1 = compact_IEEEblock_FLOAT_4_8(arrayOfFloat1, &arrayOfInt1[0], arrayOfFloat3, 
                                               elementCount, bitSizeOfInt, 
                                               bitSizeOfExpo, 0, 1, FLOAT_PACK, 0, &missingTag);
      
  unpackedFloat2 = compact_IEEEblock_FLOAT_4_8(arrayOfFloat2, &arrayOfInt1[0], arrayOfFloat3, 
                                               elementCount, bitSizeOfInt, 
                                               bitSizeOfExpo, 0, 1, FLOAT_UNPACK, 0, &missingTag);

  testError = 0;
  for ( i = 0; i < elementCount*stride; i+=stride)
    {
      if ( arrayOfFloat2[i] != arrayOfFloat1[i] )
        {
          testError = 1;
          printf("\t %d \t %f \t %f \n",  i, arrayOfFloat2[i], arrayOfFloat1[i]);
        }
    };

  if (testError == 1 )
    {
      printf(" bitSizeOfToken: %d \t bitSizeOfExpo: %d \t test not passed \n", 
             bitSizeOfInt, bitSizeOfExpo);
    }
  else
    {
      printf(" bitSizeOfToken: %d \t bitSizeOfExpo: %d \t test passed \n", 
             bitSizeOfInt, bitSizeOfExpo);
    };
  printf("\n IEEE block test finishes(double)  \n");
  printf("\n ===================================================== \n\n\n");

};













}/* end of program */
Ejemplo n.º 11
0
int GetSurfacePressure(_Champ *champ)
{
   _Champ bidon;
  int dateo,datev;
  int listeIP1[100];
  int i,ier,n,lngListe,lngMaxListe;
  int ni,nj,nk,npts;
  int cleP0,clePN,cleMT,cleGZtop,cleGZbottom,cleTTtop,cleTTbottom;
  int sommeMasque,coordonnee;
  
  float *pnm, *mt,*ztop,*zbottom,*tttop,*ttbottom,ip1top,ip1bot,tmean;
  float *temp;
  int *masque;
  int lng,gdin,gdout;
  double deltaT;
  
  int ivalide;
  float niveau;
  int versPression = -1;
  int faux = 0;
  
  char *P0 = "P0";
  char *PN = "PN";
  char *MT = "MT";
  char *ME = "ME";
  char *GZ = "GZ";
  char *TT = "TT";
  char *nomMT = MT;
  char p0[5];
  int moins1 = -1;
  static char *pasdeP0[] = {"Champ de pression a la surface non disponible\nCalcul a vos risques et perils",
      "Surface pressure field not available\nComputation done at your own risk"};
  static char *pasdeMT[] = {"Champ de topographie non disponible.\n Generation de PO impossible",
        "Topography field not available.\n Cannot generate P0 field"};
  static char *pasdePNM[] = {"Champ de pression au niveau de la mer non disponible.\n Generation de PO impossible",
        "Sea level pressure field not available.\n Cannot generate P0 field"};
  static char *pasdeGZ[] = {"Champ de geopotentiel non disponible.\n Generation de PO impossible",
        "Geopotential field not available.\n Cannot generate P0 field"};
  static char *pasdeTT[] = {"Champ de temperature non disponible.\n Generation de PO impossible",
        "Temperature field not available.\n Cannot generate P0 field"};

/*   if (champ->coupe.montagnes == NULL)
    {
    return -1;
    }*/
   
   strcpy(p0, "P0  ");
   
   lng = c_getulng();
   dateo = champ->dateo;

  ivalide = 0;
  f77name(convip)(&(champ->ip1), &niveau, &coordonnee, &versPression, NULL, &faux, (F2Cl) 0);

     
   deltaT = (champ->deet*champ->npas)/3600.0;
   f77name(incdatr)(&datev,&dateo,&deltaT);
   
   switch(coordonnee)
      {
      case METRES:
      cleP0 = c_fstinf(champ->iun, &ni, &nj, &nk,-1,"        ", -1,-1, -1," ", ME);

      if (cleP0 < 0)
         {
         MessageAvertissement(pasdeMT[lng],AVERTISSEMENT);
         return -1;
         }
      else
         {
         champ->coupe.montagnes = (float *) calloc(ni * nj * nk, sizeof(float));
         ier = c_fstluk(champ->coupe.montagnes, cleP0, &ni, &nj, &nk);
         return 0;
         }
      break;
      
      case SIGMA:
      case HYBRIDE:
      case PRESSION:
      cleP0 = c_fstinf(champ->iun, &ni, &nj, &nk, champ->datev,champ->etiket, moins1, champ->ip2, champ->ip3, champ->typvar, p0);      
      if (cleP0 < 0)
         {
         MessageAvertissement(pasdeP0[lng],AVERTISSEMENT);
         }
      else
         {
         gdin = c_ezqkdef(champ->src.ni, champ->src.nj, champ->src.grtyp, champ->src.ig1, champ->src.ig2, champ->src.ig3, champ->src.ig4, champ->iun);
         gdout = c_ezgetgdout();
         c_ezdefset(gdout,gdin);

         temp = (float *) malloc(ni * nj * nk*sizeof(float));
         ier = c_fstluk(temp, cleP0, &ni, &nj, &nk);
         if (champ->coupe.montagnes == NULL)
          {
          champ->coupe.montagnes = malloc(champ->dst.ni * champ->dst.nj * sizeof(float));
          }
         c_ezsint(champ->coupe.montagnes,temp);
         free(temp);

         return 0;
         }
            
      clePN = c_fstinf(champ->iun, &ni, &nj, &nk,
                       datev,champ->etiket, -1,
                       champ->ip2, champ->ip3, champ->typvar, PN);
          
      if (clePN < 0)
         {
         MessageAvertissement(pasdePNM[lng],AVERTISSEMENT);
         return -1;
         }
         
      cleMT = c_fstinf(champ->iun, &ni, &nj, &nk,-1,"        ", -1,-1, -1, " ", MT);
      
      if (cleMT < 0)
         {
         cleMT = c_fstinf(champ->iun, &ni, &nj, &nk,-1,"        ", -1,-1,-1," ", ME);
         nomMT = ME;
         if (cleMT < 0) 
            {
            MessageAvertissement(pasdeMT[lng], AVERTISSEMENT);
            return -1;
            }
         }
       
      lngMaxListe = 100;
      ier = c_fstinl(champ->iun, &ni, &nj, &nk, datev, champ->etiket,-1,
                     champ->ip2, champ->ip3, champ->typvar, GZ, listeIP1, &lngListe, lngMaxListe);
  
      
      FldMgrVerConsistanceGrilles(*champ, listeIP1, &lngListe);
      FldMgrVerConsistanceNiveaux(*champ, listeIP1, &lngListe);
      FldMgrTrierClesSelonIP1(listeIP1,&lngListe);
    
      if (lngListe < 2) 
         {
         MessageAvertissement(pasdeGZ[lng],AVERTISSEMENT);
         return -1;
         }

      npts = ni * nj * nk;        
      gdin = c_ezgetgdin();
      gdout = c_ezgetgdout();
      c_ezdefset(gdout,gdin);
      champ->coupe.montagnes      = (float *) calloc(npts, sizeof(float));
      pnm       =  (float *) calloc(npts, sizeof(float));
      mt       =  (float *) calloc(npts, sizeof(float));
      ztop     =  (float *) calloc(npts, sizeof(float));
      zbottom  =  (float *) calloc(npts, sizeof(float));
      tttop    = (float *) calloc(npts, sizeof(float));
      ttbottom = (float *) calloc(npts, sizeof(float));
    
      masque  = (int *)   calloc(npts, sizeof(int));

      cleGZbottom = 0;
      cleGZtop =  1;
    
      ier = c_fstluk(pnm, clePN, &ni, &nj, &nk);
      ier = c_fstluk(mt, cleMT, &ni, &nj, &nk);
    
      if (nomMT == MT)
         {
         for (i=0; i < npts; i++)
             mt[i] *= 0.1;
         }

      n = 0;

/* traitement separe de la premiere couche */
    
      sommeMasque = 0;
      bidon.cle = listeIP1[cleGZbottom];
      FldMgrGetFstPrm(&bidon);
      ip1bot = (float)bidon.ip1;
      
      ier = c_fstluk(zbottom,  listeIP1[cleGZbottom], &ni, &nj, &nk); 
      for (i=0; i < npts; i++) zbottom[i] *= 10.0;
      cleTTbottom = c_fstinf(champ->iun, &ni, &nj, &nk,-1,"        ",bidon.ip1,-1,-1," ", TT);
      if (cleTTbottom < 0)
        {
        MessageAvertissement(pasdeTT[lng],AVERTISSEMENT);
        return -1;
        }
      ier = c_fstluk(ttbottom, cleTTbottom, &ni, &nj, &nk); 
      
      for (i=0; i < npts; i++)
         {
         champ->coupe.montagnes[i] = pnm[i];
         if (mt[i] <= 0.0)
            {
            masque[i] = 1;
            }
         else
            {
            if (mt[i] >= zbottom[i])
               {
               champ->coupe.montagnes[i] = (float) ip1bot;
               }
            else
               {
               champ->coupe.montagnes[i] = pnm[i]*exp((-9.8*mt[i])/(287.0*(273+ttbottom[i])));
               masque[i] = 1;
               }
            }
         sommeMasque += masque[i];
         }
      
      bidon.cle = listeIP1[cleGZtop];
      FldMgrGetFstPrm(&bidon);
      ip1top = (float)bidon.ip1;
      
      ier = c_fstluk(ztop, listeIP1[cleGZtop], &ni, &nj, &nk); 
      for (i=0; i < npts; i++)
        {
        ztop[i] *= 10.0;
        }
   

      cleTTtop = c_fstinf(champ->iun, &ni, &nj, &nk,-1,bidon.etiket,bidon.ip1,-1,-1," ", TT);
      if (cleTTtop < 0)
        {
        MessageAvertissement(pasdeTT[lng],AVERTISSEMENT);
        return -1;
        }

      ier = c_fstluk(tttop, cleTTtop, &ni, &nj, &nk); 
      while (sommeMasque != npts && cleGZtop < lngListe)
        {
        for (i=0; i < npts; i++)
                  {
                  if (masque[i] == 0)
                    {
                    if (mt[i] >= ztop[i])
                        {
                        champ->coupe.montagnes[i] = (float) ip1top;
                        }
                    else
                        {
                        tmean = (tttop[i]+ttbottom[i])*0.5 + 273.0;
                        champ->coupe.montagnes[i] = ip1bot*(exp((-9.8*(mt[i]-zbottom[i]))/(287.0*tmean)));
                        masque[i] = 1;
                        }
                    }
                  }
   
          sommeMasque = 0;
          for (i=0; i < npts; i++)
              {
              sommeMasque += masque[i];
              zbottom[i] = ztop[i];
              ttbottom[i] = tttop[i];
              }

          ip1bot = ip1top;
          cleGZtop++;     


          bidon.cle = listeIP1[cleGZtop];
          FldMgrGetFstPrm(&bidon);
          ip1top = (float)bidon.ip1;
          ier = c_fstluk(ztop, listeIP1[cleGZtop], &ni, &nj, &nk); 
          for (i=0; i < npts; i++)
            {
            ztop[i] *= 10.0;
            }
          cleTTtop = c_fstinf(champ->iun, &ni, &nj, &nk,-1,bidon.etiket,bidon.ip1,-1,-1," ", TT);
          if (cleTTtop < 0)
              {
              MessageAvertissement(pasdeTT[lng],AVERTISSEMENT);
              return -1;
              }

          ier = c_fstluk(tttop, cleTTtop, &ni, &nj, &nk); 
          }
      
      temp = champ->coupe.montagnes;
      champ->coupe.montagnes = malloc(champ->dst.ni*champ->dst.nj*champ->dst.nk*sizeof(float));
      c_ezsint(champ->coupe.montagnes,temp);
      free(temp);
      free(pnm);
      free(mt);
      free(ztop);
      free(zbottom);
      free(tttop);
      free(ttbottom);
      free(masque);
      
      return 0;
      break;
      
/*      case PRESSION:
      cleP0 = 0;
      champ->coupe.montagnes = NULL;
      return -1;
      break;*/
      
      default:
//      cleP0 = NULL;
      cleP0 = 0;
      champ->coupe.montagnes = NULL;
      return -1;
      break;
      }
   }
Ejemplo n.º 12
0
lire_geo(ListePointsStruct *(*liste), int *nbItems, char *nomFichier[], int nbFichiers)
{
   float pts[200];
   int deuxCents = 200;
   char nomFichierGeographie[128];
   char *tmp;

   int res;
   int n,i, j, nbSeg;
   float xmin, xmax;
   float ymin, ymax;
   float latMin, latMax, lonMin, lonMax;
   int oldNbItems = 0;
   static int gdb_initialized = -1;
   
   int npts, centCinquanteHuit, code;

   if (gdb_initialized == -1)
     {
     gdb_init();
     gdb_initialized = 1;
     }
   
   NewGeoItem(liste,nbItems);
   
   tmp = (char *) getenv("GDB_PATH");

   if (tmp != NULL)
     {
     if (gdb_initialized == -1)
       {
       gdb_init();
       gdb_initialized = 1;
       }

     gdb_limit(-90.0, -180.0, 90.0, 360.0 );
     gdb_liste = *liste;
     gdb_nbItems = *nbItems;
     
     gdb_line(8,GDB_LIN_COAST,get_coastline);
     
     *liste = gdb_liste;
     *nbItems = gdb_nbItems;
     }
   else
     {
     tmp = (char *) getenv("DCW");
     
     if (tmp == NULL)
       {
       tmp = (char *) getenv("ARMNLIB");
       
       if (tmp == NULL)
        {
        printf("La valeur de la variable d'environnement ARMNLIB est inconnue... \nImpossible de continuer.\n");
        exit(-1);
        }
       else
        {
        for (n=0; n < nbFichiers; n++)
          {
          strcpy(nomFichierGeographie, tmp);
          strcat(nomFichierGeographie, nomFichier[n]);
          centCinquanteHuit = 158;
          f77name(opllfl)(&centCinquanteHuit, nomFichierGeographie, &code,(F2Cl) strlen((char *)nomFichier));

          npts = -1;
          while (npts != 0)
            {
            f77name(rdllfl)(&centCinquanteHuit, &npts, &latMax, &latMin, &lonMax, &lonMin, pts, &deuxCents);

            if (latMax < latMin)
              swapFloats(&latMin, &latMax);

            if (lonMax < lonMin)
              swapFloats(&lonMin, &lonMax);

            res = gmp_perim(&xmin, &ymin, &xmax, &ymax, &latMin, &lonMin, &latMax, &lonMax, &nbSeg);
            if (res)
              {
              gmp_trim(pts, &npts,mapOptions.resolution);
              gmp_convert(*liste, nbItems, pts, npts, xmin, ymin, xmax, ymax, nbSeg);

              for (i=oldNbItems; i < *nbItems; i++)
                {
                switch(mapOptions.styleGeo)
                  {
                  case LIGNE:
                  case TIRET:
                    TracerVecteurs(&(*liste)[i]);
                    break;

                  case POINT:
                    TracerPoints(&(*liste)[i]);
                    break;
                  }
                }
              NewGeoItem(liste,nbItems);
              oldNbItems = *nbItems-1;
              }
            }
          f77name(clllfl)(&centCinquanteHuit);
          }
        }
       }
     }
}
Ejemplo n.º 13
0
/*<----------------------------------------------------------------------------------------->*/
XtCallbackProc PeEnregistrer(Widget w, caddr_t clientData, caddr_t  callData)
{
   char nomFich[1024];
   char *nouvelleEtiquette;
   char *typFich = "STD+RND";
   int lng;
   static char *nombidon[] = {"champ_edite", "modified_field"};
   static char *succes[] = {"\nOperation completee.\n Le champ a ete ecrit dans le fichier:\n", 
			       "\nOperation successfull.\n The field has been saved in the file:\n"};
   static char *problemeFnom[] = {"\nProbleme avec l'ouverture du fichier\nOperation annulee\n", 
				     "\nCan't open file.\nOperation cancelled\n"};

   int iunSortie = 0;
   char succesStr[256];
   Arg args[2];
   int i;
   float tmp;
   int ni, nj, nk;
   int ier, dateo, deet, npas, nbits, datyp, ip1, ip2, ip3;
   int ig1,ig2,ig3,ig4,swa,fstlng,dltf,ubc,extra1,extra2,extra3;
   char grtyp[2], typvar[3], nomvar[5], etiket[13];
   float *tmpfld;
   int   *itmpfld;
   unsigned int *iunstmpfld;

   unsigned int tmpunsfld;
   int tmpintfld;
   _Champ *champ;

   FldMgrGetChamp(&champ, 0);
   
   lng = c_getulng();
   f77name(rtnozsrt)(nomFich, (F2Cl) 1024);

   i = 0;
   while (!(isspace((int)nomFich[i])))
      i++;
   nomFich[i] = '\0';
   for (i=0; i < strlen(nomFich); i++)
      nomFich[i] = tolower((int)nomFich[i]);


   if (0 == strcmp(nomFich, nombidon[lng]))
      {
      strcpy(nomFich, (char *) getenv("HOME"));
      strcat(nomFich, "/");
      strcat(nomFich, nombidon[lng]);
      }

   ier  = c_fnom(&iunSortie, nomFich, typFich, 0);
   if (ier != 0)
      {
      DesactiverTousPeWidgets();
      MessageAvertissementAux(problemeFnom[lng], AVERTISSEMENT, peWarning, peTopLevel);
      ActiverTousPeWidgets();
      return;
      }
   
   i = 0;
   XtSetArg(args[i], XmNvalue, &nouvelleEtiquette); i++;
   XtGetValues(peTextEtikRemplacement, args, i);

   for (i=strlen(nouvelleEtiquette); i < 8; i++)
      {
      nouvelleEtiquette[i] = ' ';
      }
	
   ier = c_fstouv(iunSortie, "RND+R/W");
   if (ier < 0)
      {
      DesactiverTousPeWidgets();
      MessageAvertissementAux(problemeFnom[lng], AVERTISSEMENT, peWarning, peTopLevel);
      ActiverTousPeWidgets();
      return 0;
      }

   ier = c_fstprm(champ->cle, &dateo, &deet, &npas, &ni, &nj, &nk, &nbits,
		  &datyp, &ip1, &ip2, &ip3, typvar, nomvar, etiket,
		  grtyp, &ig1, &ig2, &ig3, &ig4, &swa, &fstlng, &dltf,
		  &ubc, &extra1, &extra2, &extra3);
       
   if ((grtyp[0] == 'G' || grtyp[0] == 'A' || grtyp[0] == 'B') && ig2 == 1)
      f77name(permut)(champ->fld, &ni, &nj);
   
   if (datyp == 2)
      {
      for (tmpfld = champ->fld; tmpfld < (champ->fld + ni * nj); tmpfld++)
	 {
	 tmpintfld = (int) *tmpfld;
	 memcpy(tmpfld, &tmpintfld, sizeof(float));
	 }
      }
   
   if (datyp == 4)
      {
      for (tmpfld = champ->fld; tmpfld < (champ->fld + ni * nj); tmpfld++)
	 {
	 tmpunsfld = (unsigned int) *tmpfld;
	 memcpy(tmpfld, &tmpunsfld, sizeof(float));
	 }
      }

   ier = c_fstecr(champ->fld, champ->fld, -nbits, iunSortie, 
		  champ->dateo, deet, npas, mapInfo.ni, mapInfo.nj, 1,
		  ip1, ip2, ip3, champ->typvar, 
		  champ->nomvar, nouvelleEtiquette, &mapInfo.type,
		  mapInfo.ig1, mapInfo.ig2, mapInfo.ig3, mapInfo.ig4, datyp, 1);

   ier = c_fstfrm(iunSortie);
   ier = c_fclos(iunSortie);

   strcpy(succesStr, succes[lng]);
   strcat(succesStr, nomFich);
   strcat(succesStr, "\n");

   DesactiverTousPeWidgets();
   MessageAvertissementAux(succesStr, INFO, peInfo, peTopLevel);
   ActiverTousPeWidgets();
   
   if ((grtyp[0] == 'G' || grtyp[0] == 'A' || grtyp[0] == 'B') && ig2 == 1)
      f77name(permut)(champ->fld, &ni, &nj);
   
   if (datyp == 2)
      {
      for (itmpfld = (int *)champ->fld; itmpfld < (int *)(champ->fld + ni * nj); itmpfld++)
	 {
	 tmp = (float) *itmpfld;
	 memcpy(itmpfld, &tmp, sizeof(int));
	 }
      }
   
   if (datyp == 4)
      {
      for (iunstmpfld = (unsigned int *)champ->fld; iunstmpfld < (unsigned int *)(champ->fld + ni * nj); iunstmpfld++)
	 {
	 tmp = (float) *iunstmpfld;
	 memcpy(iunstmpfld, &tmp, sizeof(unsigned int));
	 }
      }

   indCourantPile = -1;
   nbTotalPile = 0;
   MAJLabelsPile(nbTotalPile, nbTotalPile);
   DesactiverAuxPeWidgets();
   champ->champModifie = False;
   return 0; 
   }
Ejemplo n.º 14
0
/** ARGSUSED **/
XtCallbackProc PeEditerValeurs(Widget w, caddr_t clientData, caddr_t  callData)
{
   int lng;
   static char *pasAvecDesChampsVectoriels[] = {"\nCette fonction ne s'applique pas\naux champs vectoriels\n", 
						   "\nThis function does not work\nwith vector fields\n"};
   
   int bouton, event;
   int x0, y0, xsize, ysize, x1, y1, x2, y2;
   int nbMenus;
   char TitreMenu[3][80];
   int temp;
   int i,j,k,n;
   float newX1, newY1, newX2, newY2;
   float ancienneValeur, valeurPloguee, val;
   PointEditionStruct *anciennesValeurs;
   char  *txtValeurPloguee;
   int mode;
   Arg args[1];
   int oldIndCourantPile;
   _Champ *champ;

   FldMgrGetChamp(&champ, 0);
   mode = (int)clientData;
   anciennesValeurs = NULL;
   ancienneValeur = 0.0;

   if (xc.statuts[EN_TRAIN_DE_DESSINER])
      {
      Beeper();
      return 0;
      }
   
   if (champ->natureTensorielle == VECTEUR)
      {
      lng = c_getulng();
      DesactiverTousPeWidgets();
      MessageAvertissementAux(pasAvecDesChampsVectoriels[lng], AVERTISSEMENT, peWarning, peTopLevel);
      ActiverTousPeWidgets();
      return 0;
      }

   oldIndCourantPile = indCourantPile;
   DesactiverTousPeWidgets();

   i = 0;
   XtSetArg(args[i], XmNvalue, &txtValeurPloguee); i++;
   XtGetValues(peTextValRemplacement, args, i);

   sscanf(txtValeurPloguee, "%e", &valeurPloguee);

   InvertWidget(w);

   xc.statuts[EN_TRAIN_DE_DESSINER] = TRUE;
   nbMenus = 0;
   
   event = 0;
   while (event != RESET)
      {
      f77name(souris)(&bouton, &event, 
	      &x0, &y0, &xsize, &ysize, 
	      &x1, &y1, &x2, &y2, TitreMenu, &nbMenus, (F2Cl) 80);
      
      if (x2 < x1)
	 {
	 temp = x1;
	 x1 = x2;
	 x2 = temp;
	 }
      
      if (y2 < y1)
	 {
	 temp = y1;
	 y1 = y2;
	 y2 = temp;
	 }
      
      x1 -= x0; x2 -= x0;
      y1 -= y0; y2 -= y0;
      
      c_wgliax(&newX1, &newY1, x1, y1);
      c_wgliax(&newX2, &newY2, x2, y2);
      c_fxfy2xy(&newX1, &newY1, newX1, newY1);
      c_fxfy2xy(&newX2, &newY2, newX2, newY2);
      
      switch(event)
	 {
	 case DRAG:
	 champ->champModifie = True;
	 newX1 = (float)ROUND(newX1+0.5);
	 newY1 = (float)ROUND(newY1+0.5);
	 newX2 = (float)ROUND(newX2-0.5);
	 newY2 = (float)ROUND(newY2-0.5);


	 if (newX1 < 1.0 || newX2 > (float)mapInfo.ni || newY1 < 1.0 || newY2 > (float)mapInfo.nj)
	    {
	    Beeper();
	    }
	 else
	    {
	    anciennesValeurs = (PointEditionStruct *) calloc(((int)(newY2 - newY1)+1)*((int)(newX2 - newX1)+1), 
							     sizeof(PointEditionStruct));
	    n = 0;
	    for (i=(int)newX1; i <= (int)newX2; i++)
	       {
	       for (j=(int)newY1; j <= (int)newY2; j++)
		  {
		  k=C2FTN(i-1,j-1,mapInfo.ni);
		  anciennesValeurs[n].ind = k;
		  anciennesValeurs[n].val = champ->fld[k];
		  if (mode == MODIFIER)
		     val = valeurPloguee;
		  else
		     val = champOriginal.fld[k];
		  
		  champ->fld[k] = val;
		  n++;
		  }
	       }
	    
	    AfficherPixelBarre(newX1, newY1, newX2, newY2);
	    AjouterItemDansLaPile(DRAG, valeurPloguee, ancienneValeur,anciennesValeurs,(int)newX1,(int)newY1,(int)newX2,(int)newY2); 
	    }
	 break;
	 
	 case CLIC:
	 if (newX1 < 1.0 || newX2 > (float)mapInfo.ni || newY1 < 1.0 || newY2 > (float)mapInfo.nj)
	    {
	    Beeper();
	    }
	 else
	    {
	    champ->champModifie = True;
	    newX1 = (float)ROUND(newX1);
	    newY1 = (float)ROUND(newY1);
	    newX2 = (float)ROUND(newX2);
	    newY2 = (float)ROUND(newY2);
	    
	    k=C2FTN(ROUND(newX1)-1,ROUND(newY1)-1,mapInfo.ni);
	    ancienneValeur = champ->fld[k];
	    anciennesValeurs = NULL;
	    newX2 = newX1;
	    newY2 = newY1;
	    if (mode == MODIFIER)
	       val = valeurPloguee;
	    else
	       val = champOriginal.fld[k];
	    champ->fld[k] = val;
	    AfficherPixelBarre(newX1, newY1, newX2, newY2);
	    AjouterItemDansLaPile(CLIC, val, ancienneValeur, anciennesValeurs, (int)newX1, (int)newY1, (int)newX2, (int)newY2);
	    }
	 break;

	 case BACK_CLIC:
	 PeAfficher( NULL, NULL, NULL);

	 break;

	 case NIL:
	 event = RESET;
	 break;

	 default:
	 break;
	 }

      }

   if (champ->champModifie)
      {
      ActiverWidget(peRemettreValeurs);
      ActiverAuxPeWidgets();
      }

   ActiverWidget(peEditerValeurs);
   ActiverTextFields();
   PeActiverBoutons();

   if (champ->champModifie && indCourantPile > oldIndCourantPile)
      {
      PeAfficher(NULL, NULL, NULL);
      }
   xc.statuts[EN_TRAIN_DE_DESSINER] = FALSE;
   InvertWidget(w);
   return 0;

   }
Ejemplo n.º 15
0
ftnword f77name(rpn_comm_softbarrier_init_all)(){
	ftnword world=MPI_COMM_WORLD;
	return(f77name(rpn_comm_softbarrier_init)(&world));
}
Ejemplo n.º 16
0
fst2xml_(int argc, char **argv)
{

  char fstFile[256], xmlFile[256];
  char encoding[16];
  char format[32];
  int ok, iun, key, tokens_per_line;
  
  char *liste[5], lcl_liste[5][256], *def[5], lcl_def[5][16], val[5][256]; 
  int i, n, npos, nptsRLE;
  int ni, nj, nk;
  
  int ier, ip1, ip2, ip3, ig1, ig2, ig3, ig4;
  int  dateo, datev, datyp, deet,nbits, npak, npas,swa, lng;
  int dltf, ubc, extra1, extra2, extra3;
  int isallocated, multi;
    
  char etiket[16], nomvar[8], typvar[4], grtyp[2];
  char xmldateo[32], xmldatev[32];
  char xmlip1[32], xmlip2[32], xmlip3[32];
  double nhours;
  
  float *fld;
  int *ifld;

  FILE *xmlfd;
  
  strcpy(lcl_liste[0], "fst.");
  strcpy(lcl_liste[1], "xml.");
  strcpy(lcl_liste[2], "encoding.");
  strcpy(lcl_liste[3], "format.");
  strcpy(lcl_liste[4], "tpl.");

  liste[0] = (char *) lcl_liste[0];
  liste[1] = (char *) lcl_liste[1];
  liste[2] = (char *) lcl_liste[2];
  liste[3] = (char *) lcl_liste[3];
  liste[4] = (char *) lcl_liste[4];

  strcpy(lcl_def[0],"bidon.fst");
  strcpy(lcl_def[1],"bidon.xml");
  strcpy(lcl_def[2],"ascii");
  strcpy(lcl_def[3],"%14.6g");
  strcpy(lcl_def[4],"8");

  def[0] = (char *) lcl_def[0];
  def[1] = (char *) lcl_def[1];
  def[2] = (char *) lcl_def[2];
  def[3] = (char *) lcl_def[3];
  def[4] = (char *) lcl_def[4];

  
  
  for (i = 0; i < 5; i++)
    {
    strcpy(val[i], def[i]);
    }
  
  npos = 0;
  c_ccard(argv, argc, (char **) liste, val, (char **) def, 5, &npos);
    
  strcpy(fstFile, val[0]);
  strcpy(xmlFile, val[1]);
  strcpy(encoding, val[2]);
  strcpy(format,  val[3]);
  sscanf(val[4], "%d", &tokens_per_line);

  iun = 1;
  c_fnom(iun, fstFile, "RND+R/O", 0);
  ier = c_fstouv(iun, "RND");

  if (0 == strcmp(val[1], def[1]))
    {
    xmlfd = stdout;
    ier = c_fstopc("MSGLVL", "FATALE", 0);
    }
  else
    {
    xmlfd = fopen(xmlFile, "w");
    }

  if (xmlfd == NULL)
    {
    fprintf(stderr, "Cannot open output file... Exiting...");
    exit(13);
    }

  fprintf(xmlfd, "%s\n", "<?xml version='1.0' encoding='utf-8' standalone='yes'?>");
  fprintf(xmlfd, "%s\n", "<rpn-standard-file>");


  key = c_fstinf(iun, &ni, &nj, &nk, -1,"            ", -1, -1, -1, "  ", "    ");
  do
    {
    strcpy(etiket, "            ");
    strcpy(nomvar, "    ");
    strcpy(typvar, "  ");
    strcpy(grtyp, " ");
    
    ier = c_fstprm(key, &dateo, &deet, &npas, &ni, &nj, &nk, &nbits,
            &datyp, &ip1, &ip2, &ip3, typvar, nomvar, etiket,
            grtyp, &ig1, &ig2, &ig3, &ig4, &swa, &lng, &dltf,
            &ubc, &extra1, &extra2, &extra3);
    if (nbits > 32) 
      multi = 2;
    else
      multi = 1;

    xmlconvip(xmlip1, ip1);
    nhours = (double) npas * deet / 3600.0;
    f77name(incdatr)(&datev, &dateo, &nhours);
    xmlconvdate(xmldateo, dateo);
    xmlconvdate(xmldatev, datev);
    
    etiket[12] = '\0';
    nomvar[4] = '\0';
    typvar[2] = '\0';
    
    /*---------------------------------------------------------------*/
    fprintf(xmlfd, "%s\n", "<fstrecord>");
    fprintf(xmlfd, "\t%s%s%s\n", "<nomvar>", nomvar, "</nomvar>");
    fprintf(xmlfd, "\t\t%s%s%s\n", "<typvar>", typvar, "</typvar>");
    fprintf(xmlfd, "\t\t%s%s%s\n", "<etiket>", etiket, "</etiket>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<ip1>", ip1, "</ip1>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<ip2>", ip2, "</ip2>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<ip3>", ip3, "</ip3>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<ni>", ni, "</ni>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<nj>", nj, "</nj>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<nk>", nk, "</nk>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<dateo>", dateo, "</dateo>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<datev>", datev, "</datev>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<deet>", deet, "</deet>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<npas>", npas, "</npas>");
    fprintf(xmlfd, "\t\t%s%s%s\n", "<grtyp>", grtyp, "</grtyp>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<ig1>", ig1, "</ig1>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<ig2>", ig2, "</ig2>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<ig3>", ig3, "</ig3>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<ig4>", ig4, "</ig4>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<nbits>", nbits, "</nbits>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<datyp>", datyp, "</datyp>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<swa>", swa, "</swa>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<lng>", lng, "</lng>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<dltf>", dltf, "</dltf>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<ubc>", ubc, "</ubc>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<extra1>", extra1, "</extra1>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<extra2>", extra2, "</extra2>");
    fprintf(xmlfd, "\t\t%s%d%s\n", "<extra3>", extra3, "</extra3>");
    
    fprintf(xmlfd, "\t\t%s%s%s\n", "<level>", xmlip1, "</level>");
    fprintf(xmlfd, "\t\t%s%s%s\n", "<date-of-origin>", xmldateo, "</date-of-origin>");
    fprintf(xmlfd, "\t\t%s%s%s\n", "<date-of-validity>", xmldatev, "</date-of-validity>");

    /*---------------------------------------------------------------*/


    fprintf(xmlfd, "\t\t%s\n", "<fstdata encoding='ASCII' format='14.6g' orientation='south-to-north'>");
    fprintf(xmlfd, "\t\t%s", "<values>");

    switch (datyp)
      {
      case 1:
      case 5:
      case 6:
      case 133:
      case 134:
        fld = (float *) malloc(ni * nj * nk * sizeof(float) * multi);
        isallocated = 1;
        ier = c_fstluk(fld, key, &ni, &nj, &nk);
          for (i = 0; i < ni * nj * nk; i++)
            {
            fprintf(xmlfd, format, fld[i]);
            if (0 == ((i+1) % tokens_per_line))
              {
              fprintf(xmlfd, "\n");
              }
            }
      break;
        
        case 2:
        case 4:
        case 130:
        case 132:
          ifld = (int *) malloc(ni * nj * nk * sizeof(int) * multi);
	  isallocated = 2;
          ier = c_fstluk(ifld, key, &ni, &nj, &nk);
            for (i = 0; i < ni * nj * nk; i++)
              {
              fprintf(xmlfd, format, ifld[i]);
              if (0 == ((i+1) % tokens_per_line))
                {
                fprintf(xmlfd, "\n");
                }
              }
        break;
  
        default:
	  fprintf(stderr,"Cannot process Datyp %d , skipping record nomvar=%s\n\n",datyp,nomvar);
	  isallocated = 0;

	break;
      }
      fprintf(xmlfd, "\t\t%s\n", "</values>");
      fprintf(xmlfd, "\t\t%s\n", "</fstdata>");
      fprintf(xmlfd, "%s\n", "</fstrecord>");
      
      switch (isallocated)
        {
          case 0:
	    break;
          case 1:
	    free(fld);
            break;
          case 2:
            free(ifld);
            break;
       }

      key = c_fstsui(iun, &ni, &nj, &nk);
    } while (key >= 0);
  
  fprintf(xmlfd, "%s\n", "</rpn-standard-file>");
  fclose(xmlfd);
  ier = c_fstfrm(iun);
  ier = c_fclos(iun);
}
Ejemplo n.º 17
0
int c_gmpset(char grtyp, int ni, int nj, int ig1, int ig2, int ig3, int ig4)
{
   int iig1, iig2, iig3, iig4;
   int gdid,res;
   char lgrtyp[2];

   c_gmpinit();

   iig1 = ig1;
   iig2 = ig2;
   iig3 = ig3,
   iig4 = ig4;

   gdxmin = 1.0;
   gdxmax = (float) (ni);
   gdymin = 1.0;
   gdymax = (float) (nj);

   lgrtyp[0] = grtyp;
   lgrtyp[1] = '\0';
   mapInfo.gdid = c_ezqkdef(ni, nj, lgrtyp, ig1, ig2, ig3, ig4, 0);

   mapInfo.ig1 = ig1;
   mapInfo.ig2 = ig2;
   mapInfo.ig3 = ig3;
   mapInfo.ig4 = ig4;

   switch(grtyp)
      {
      case 'A':
      case 'G':
      case 'U':
      mapInfo.type = grtyp;
      mapInfo.xOrigine = 1.0;
      mapInfo.yOrigine = 1.0;
      mapInfo.ni = ni;
      mapInfo.nj = nj;
      mapInfo.hemisphere = ig1;
      mapInfo.indOrientation = NORD;
      mapInfo.deltaLon = 360.0 / (float) (mapInfo.ni);
      mapInfo.lonOrigine = 0.0;
      switch (mapInfo.hemisphere)
         {
         case GLOBAL:
         mapInfo.deltaLat = 180.0 / (float) (mapInfo.nj);
         mapInfo.latOrigine = -90.0 + mapInfo.deltaLat * 0.50;
         mapInfo.lonOrigine = 0.0;
         break;

         case NORD:
         mapInfo.deltaLat = 90.0 / (float) (mapInfo.nj);
         mapInfo.latOrigine = mapInfo.deltaLat * 0.50;
         break;

         case SUD:
         mapInfo.deltaLat = 90.0 / (float) (mapInfo.nj);
         mapInfo.latOrigine = -90.0 + mapInfo.deltaLat * 0.50;
         break;
         }
      mapFlags.typeValide = OUI;
      break;

      case 'O':
      mapInfo.type = grtyp;
      mapInfo.xOrigine = 1.0;
      mapInfo.yOrigine = 1.0;
      mapInfo.ni = ni;
      mapInfo.nj = nj;
      mapInfo.hemisphere = GLOBAL;
      mapInfo.indOrientation = NORD;
      mapInfo.deltaLon = 1.0;
      mapInfo.lonOrigine = 0.0;
      mapInfo.deltaLat = 180.0 / (float) (mapInfo.nj);
      mapInfo.latOrigine = -90.0 + mapInfo.deltaLat * 0.50;
      mapInfo.lonOrigine = 0.0;
      mapFlags.typeValide = OUI;
      break;

      case 'B':
      mapInfo.type = grtyp;
      mapInfo.xOrigine = 1.0;
      mapInfo.yOrigine = 1.0;
      mapInfo.ni = ni;
      mapInfo.nj = nj;
      mapInfo.hemisphere = ig1;
      mapInfo.indOrientation = NORD;
      mapInfo.deltaLon = 360.0 / (float) (mapInfo.ni - 1);
      mapInfo.lonOrigine = 0.0;
      switch (mapInfo.hemisphere)
         {
         case GLOBAL:
         mapInfo.deltaLat = 180.0 / (float) (mapInfo.nj - 1);
         mapInfo.latOrigine = -90.0;
         break;

         case NORD:
         mapInfo.deltaLat = 90.0 / (float) (mapInfo.nj - 1);
         mapInfo.latOrigine = 0.0;
         break;

         case SUD:
         mapInfo.deltaLat = 90.0 / (float) (mapInfo.nj - 1);
         mapInfo.latOrigine = -90.0;
         break;
         }
      mapFlags.typeValide = OUI;
      break;

      case 'E':
      mapInfo.type = grtyp;
      mapInfo.hemisphere = GLOBAL;
      mapInfo.indOrientation = NORD;
      mapInfo.ni = ni;
      mapInfo.nj = nj;
      f77name(cigaxg)(lgrtyp,&mapInfo.elat1,&mapInfo.elon1,&mapInfo.elat2,&mapInfo.elon2,
                      &iig1, &iig2, &iig3, &iig4,(F2Cl) strlen(lgrtyp));
      mapFlags.typeValide = OUI;
      break;

      case 'L':
      mapInfo.type = grtyp;
      mapInfo.hemisphere = GLOBAL;
      mapInfo.indOrientation = NORD;
      mapInfo.xOrigine = 1.0;
      mapInfo.yOrigine = 1.0;
      mapInfo.ni = ni;
      mapInfo.nj = nj;
      f77name(cigaxg)(lgrtyp,  &mapInfo.latOrigine, &mapInfo.lonOrigine, &mapInfo.deltaLat, &mapInfo.deltaLon,
                      &iig1, &iig2, &iig3, &iig4,(F2Cl) strlen(lgrtyp));
      if (mapInfo.lonOrigine >= 180)
         mapInfo.lonOrigine -= 360.0;
      mapFlags.typeValide = OUI;
      break;

      case 'N':
      mapInfo.type = grtyp;
      mapInfo.ni = ni;
      mapInfo.nj = nj;
      mapInfo.hemisphere = NORD;
      mapInfo.indOrientation = NORD;
      f77name(cigaxg)(lgrtyp, &mapInfo.PosXDuPole, &mapInfo.PosYDuPole,
              &mapInfo.PasDeGrille, &mapInfo.AngleGreenwich,
              &iig1, &iig2, &iig3, &iig4,(F2Cl) strlen(lgrtyp));
      mapFlags.typeValide = OUI;
      break;

      case 'S':
      mapInfo.type = grtyp;
      mapInfo.ni = ni;
      mapInfo.nj = nj;
      mapInfo.hemisphere = SUD;
      mapInfo.indOrientation = NORD;
      f77name(cigaxg)(lgrtyp, &mapInfo.PosXDuPole, &mapInfo.PosYDuPole,
              &mapInfo.PasDeGrille, &mapInfo.AngleGreenwich,
              &iig1, &iig2, &iig3, &iig4,(F2Cl) strlen(lgrtyp));
      mapFlags.typeValide = OUI;
      break;

      case 'T':
      mapInfo.type = grtyp;
      mapInfo.ni = ni;
      mapInfo.nj = nj;
      mapInfo.hemisphere = NORD;
      mapInfo.indOrientation = NORD;
      f77name(cigaxg)(lgrtyp, &mapInfo.PasDeGrille, &mapInfo.AngleGreenwich,
		      &mapInfo.latOrigine, &mapInfo.lonOrigine,
              &iig1, &iig2, &iig3, &iig4,(F2Cl) strlen(lgrtyp));
      mapFlags.typeValide = OUI;
      break;

      case '!':
      mapInfo.type = grtyp;
      mapInfo.ni = ni;
      mapInfo.nj = nj;
      mapInfo.hemisphere = NORD;
      mapInfo.indOrientation = NORD;
      f77name(cigaxg)(lgrtyp, &mapInfo.PasDeGrille, &mapInfo.AngleGreenwich,
		      &mapInfo.latOrigine, &mapInfo.lonOrigine,
              &iig1, &iig2, &iig3, &iig4,(F2Cl) strlen(lgrtyp));
      mapFlags.typeValide = OUI;
      break;

      default:
      mapFlags.typeValide = NON;
      return -1;
      }

   res = ComparerMapInfos(oldMapInfo, mapInfo);
   if (res == PAS_PAREIL)
      {
      mapFlags.lu[CONTINENTS] = NON;
      mapFlags.lu[LATLON] = NON;
      }

   CopierMapInfos(&oldMapInfo, &mapInfo);
   return 1;
   }