Download convt.procedur

Back to the list

   1 : * CONVT     PROCEDUR  MAUGIS    07/10/26    21:15:15     5712           
   2 : ************************************************************************
   3 : * NOM         : CONVT
   4 : * DESCRIPTION : convertit un temps (s) en une chaîne de caractères
   5 : *               contenant ce temps exprimé dans l'unité pertinente
   6 : *               (fs,ps,ns,us,ms,s,h,j,a)
   7 : *
   8 : * LANGAGE     : GIBIANE-CAST3M
   9 : * AUTEUR      : Pascal MAUGIS (CEA/DEN/DM2S/SFME/MTMS)
  10 : *               mél : maugis@semt2.smts.cea.fr
  11 : *
  12 : **********************************************************************
  13 : *
  14 : * VERSION    : v2, 11/02/2003, version évoluée
  15 : * HISTORIQUE : v1, 11/02/2003, création
  16 : * HISTORIQUE : v2, 29/07/2004, chgt nom de @CONVT en CONVT
  17 : * HISTORIQUE : v3, 07/08/2007, incorpore plus d'unités
  18 : * HISTORIQUE : v4, 07/09/2007, données des unités possible en minuscule
  19 : *                              ou anglaises
  20 : *
  21 : ************************************************************************
  22 : * Prière de PRENDRE LE TEMPS de compléter les commentaires
  23 : * en cas de modification de ce sous-programme afin de faciliter
  24 : * la maintenance !
  25 : ************************************************************************
  26 : *
  27 : *
  28 : 'DEBPROC' CONVT tps*'FLOTTANT' nn/'ENTIER' unit/'MOT' ;
  29 : 
  30 : * si nul, on ne convertit ni n'affiche d'unité
  31 :   'SI' ('EGA' tps 0.) ;
  32 :      out = '0' ;
  33 :      'QUITTER' CONVT ;
  34 :   'FINSI' ;
  35 : 
  36 : * nombre de chiffres après la virgule
  37 :   'SI' ('NON' ('EXISTE' nn)) ;
  38 :     nn = 2 ;
  39 :   'FINSI' ;
  40 : 
  41 : * unité cible (parmi US,MS,S,H,J,D,A,Y)
  42 :   LIUNIT = 'MOTS' 'FS' 'PS' 'NS' 'US' 'MS' 'S' 'H' 'J' 'D' 'A' 'Y'
  43 :                   'fs' 'ps' 'ns' 'us' 'ms' 's' 'h' 'j' 'd' 'a' 'y' ;
  44 : 
  45 :   'SI' ('NON' ('EXISTE' unit)) ;
  46 :      'SI'           (tps < 1.d-12) ;
  47 :          unit = 'MOT' 'FS' ;
  48 :      'SINON' ; 'SI' (tps < 1.d-9) ;
  49 :          unit = 'MOT' 'PS' ;
  50 :      'SINON' ; 'SI' (tps < 1.d-6) ;
  51 :          unit = 'MOT' 'NS' ;
  52 :      'SINON' ; 'SI' (tps < 1.d-3) ;
  53 :          unit = 'MOT' 'US' ;
  54 :      'SINON' ; 'SI' (tps < 1.) ;
  55 :          unit = 'MOT' 'MS' ;
  56 :      'SINON' ; 'SI' (tps < 3600.) ;
  57 :          unit = 'MOT' 'S' ;
  58 :      'SINON' ; 'SI' (tps < (3600. * 24.)) ;
  59 :          unit = 'MOT' 'H' ;
  60 :      'SINON' ; 'SI' (tps < (3600. * 24. * 365.25)) ;
  61 :          unit = 'MOT' 'J' ;
  62 :      'SINON' ;
  63 :          unit = 'MOT' 'A' ;
  64 :      'FINSI' ;
  65 :      'FINSI' ;
  66 :      'FINSI' ;
  67 :      'FINSI' ;
  68 :      'FINSI' ;
  69 :      'FINSI' ;
  70 :      'FINSI' ;
  71 :      'FINSI' ;
  72 :   'SINON' ;
  73 :      'SI' ('NON' ('EXISTE' liunit unit)) ;
  74 :         'ERREUR' 'Unité de temps ' UNIT ' non reconnue' ;
  75 :      'FINSI' ;
  76 :   'FINSI' ;
  77 :   
  78 : * détermination coef de conversion    
  79 :   'SI' (('EGA' unit 'FS') 'OU' ('EGA' unit 'fs')) ;
  80 :      coef = 1.d15 ;
  81 :      ntps = 'MOT'  'fs' ;
  82 :   'FINSI' ;
  83 :   'SI' (('EGA' unit 'PS') 'OU' ('EGA' unit 'ps')) ;
  84 :      coef = 1.d12 ;
  85 :      ntps = 'MOT'  'ps' ;
  86 :   'FINSI' ;
  87 :   'SI' (('EGA' unit 'NS') 'OU' ('EGA' unit 'ns')) ;
  88 :      coef = 1.d9 ;
  89 :      ntps = 'MOT'  'ns' ;
  90 :   'FINSI' ;
  91 :   'SI' (('EGA' unit 'US') 'OU' ('EGA' unit 'us')) ;
  92 :      coef = 1.d6 ;
  93 :      ntps = 'MOT'  'us' ;
  94 :   'FINSI' ;
  95 :   'SI' (('EGA' unit 'MS') 'OU' ('EGA' unit 'ms')) ;
  96 :      coef = 1.d3;
  97 :      ntps = 'MOT'  'ms' ;
  98 :   'FINSI' ;
  99 :   'SI' (('EGA' unit 'S') 'OU' ('EGA' unit 's')) ;
 100 :      coef = 1. ;
 101 :      ntps = 'MOT'  's' ;
 102 :   'FINSI' ;
 103 :   'SI' (('EGA' unit 'H') 'OU' ('EGA' unit 'h')) ;
 104 :      coef = 1. / 3600. ;
 105 :      ntps = 'MOT'  'h' ;
 106 :   'FINSI' ;
 107 :   'SI' (('EGA' unit 'J') 'OU' ('EGA' unit 'j')) ;
 108 :      coef = 1. / (3600. * 24.) ;
 109 :      ntps = 'MOT'  'j' ;
 110 :   'FINSI' ;
 111 :   'SI' (('EGA' unit 'D') 'OU' ('EGA' unit 'd')) ;
 112 :      coef = 1. / (3600. * 24.) ;
 113 :      ntps = 'MOT'  'd' ;
 114 :   'FINSI' ;
 115 :   'SI' (('EGA' unit 'A') 'OU' ('EGA' unit 'a')) ;
 116 :      coef = 1. / (3600. * 24. * 365.25) ;
 117 :      ntps = 'MOT'  'a' ;
 118 :   'FINSI' ;
 119 :   'SI' (('EGA' unit 'Y') 'OU' ('EGA' unit 'y')) ;
 120 :      coef = 1. / (3600. * 24. * 365.25) ;
 121 :      ntps = 'MOT'  'y' ;
 122 :   'FINSI' ;
 123 : 
 124 : * convertion  
 125 : out = 'CHAINE' (@FIX (tps * coef) nn) ntps ;
 126 : 
 127 : 'FINPROC' out ;
 128 :  
 129 :  

© Cast3M 2003 - All rights reserved.
Disclaimer