WorkWithlistdatavariable.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /******************************************************************************/
  2. /* */
  3. /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */
  4. /* */
  5. /* Copyright or or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */
  6. /* Cyril Mazauric (Cyril_Mazauric@yahoo.fr) */
  7. /* This software is governed by the CeCILL-C license under French law and */
  8. /* abiding by the rules of distribution of free software. You can use, */
  9. /* modify and/ or redistribute the software under the terms of the CeCILL-C */
  10. /* license as circulated by CEA, CNRS and INRIA at the following URL */
  11. /* "http://www.cecill.info". */
  12. /* */
  13. /* As a counterpart to the access to the source code and rights to copy, */
  14. /* modify and redistribute granted by the license, users are provided only */
  15. /* with a limited warranty and the software's author, the holder of the */
  16. /* economic rights, and the successive licensors have only limited */
  17. /* liability. */
  18. /* */
  19. /* In this respect, the user's attention is drawn to the risks associated */
  20. /* with loading, using, modifying and/or developing or reproducing the */
  21. /* software by the user in light of its specific status of free software, */
  22. /* that may mean that it is complicated to manipulate, and that also */
  23. /* therefore means that it is reserved for developers and experienced */
  24. /* professionals having in-depth computer knowledge. Users are therefore */
  25. /* encouraged to load and test the software's suitability as regards their */
  26. /* requirements in conditions enabling the security of their systems and/or */
  27. /* data to be ensured and, more generally, to use and operate it in the */
  28. /* same conditions as regards security. */
  29. /* */
  30. /* The fact that you are presently reading this means that you have had */
  31. /* knowledge of the CeCILL-C license and that you accept its terms. */
  32. /******************************************************************************/
  33. /* version 1.7 */
  34. /******************************************************************************/
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37. #include <string.h>
  38. #include "decl.h"
  39. /******************************************************************************/
  40. /* Add_Data_Var_1 */
  41. /******************************************************************************/
  42. /* This subroutine is used to add a record to List_Data_Var */
  43. /******************************************************************************/
  44. /* _______ _______ _______ _______ _______ */
  45. /* + + + + + + + + + + */
  46. /* + NEW +--->+ data +--->+ data +--->+ data +--->+ data+ */
  47. /* +______+ +______+ +______+ +______+ +______+ */
  48. /* */
  49. /******************************************************************************/
  50. void Add_Data_Var_1 (listvar **curlist,char *name,char *values)
  51. {
  52. listvar *newvar;
  53. char ligne[LONG_M];
  54. // if ( firstpass == 1 )
  55. // {
  56. newvar=(listvar *)calloc(1,sizeof(listvar));
  57. newvar->var=(variable *)calloc(1,sizeof(variable));
  58. /* */
  59. Init_Variable(newvar->var);
  60. /* */
  61. if ( inmoduledeclare == 1 ) newvar->var->v_module=1;
  62. strcpy(newvar->var->v_nomvar,name);
  63. strcpy(newvar->var->v_subroutinename,subroutinename);
  64. strcpy(newvar->var->v_modulename,curmodulename);
  65. strcpy(newvar->var->v_commoninfile,cur_filename);
  66. if (strchr(values,',') && strncasecmp(values,"'",1))
  67. sprintf(ligne,"(/%s/)",values);
  68. else
  69. strcpy(ligne,values);
  70. strcpy(newvar->var->v_initialvalue,ligne);
  71. Save_Length(ligne,14);
  72. newvar->suiv = NULL;
  73. if ( ! (*curlist) )
  74. {
  75. *curlist = newvar ;
  76. }
  77. else
  78. {
  79. newvar->suiv = *curlist;
  80. *curlist = newvar;
  81. }
  82. // }
  83. }
  84. void Add_Data_Var_Names_01 (listvar **curlist,listname *l1,listname *l2)
  85. {
  86. listvar *newvar;
  87. listvar *tmpvar;
  88. listname *tmpvar1;
  89. listname *tmpvar2;
  90. variable *found_var = NULL;
  91. tmpvar1 = l1;
  92. tmpvar2 = l2;
  93. while (tmpvar1)
  94. {
  95. newvar = (listvar *) calloc(1,sizeof(listvar));
  96. newvar->var = (variable *) calloc(1,sizeof(variable));
  97. Init_Variable(newvar->var);
  98. if ( inmoduledeclare == 1 ) newvar->var->v_module=1;
  99. found_var = get_variable_in_list_from_name(List_Common_Var, tmpvar1->n_name);
  100. if ( ! found_var ) found_var = get_variable_in_list_from_name(List_Global_Var,tmpvar1->n_name);
  101. if ( ! found_var ) found_var = get_variable_in_list_from_name(List_SubroutineDeclaration_Var,tmpvar1->n_name);
  102. if ( found_var && found_var->v_nbdim > 0 )
  103. {
  104. printf("##############################################################################################################\n");
  105. printf("## CONV Error : arrays in data_stmt_object lists not yet supported. Please complain to the proper authorities.\n");
  106. printf("## variable name : %s (in %s:%s:%s)\n", found_var->v_nomvar, found_var->v_modulename,
  107. found_var->v_subroutinename, found_var->v_commonname);
  108. exit(1);
  109. }
  110. strcpy(newvar->var->v_nomvar,tmpvar1->n_name);
  111. strcpy(newvar->var->v_subroutinename,subroutinename);
  112. strcpy(newvar->var->v_modulename,curmodulename);
  113. strcpy(newvar->var->v_commoninfile,cur_filename);
  114. strcpy(newvar->var->v_initialvalue,tmpvar2->n_name);
  115. Save_Length(tmpvar2->n_name,14);
  116. newvar->suiv = NULL;
  117. if ( *curlist != NULL )
  118. {
  119. tmpvar = *curlist;
  120. while (tmpvar->suiv)
  121. tmpvar = tmpvar->suiv;
  122. tmpvar->suiv = newvar;
  123. }
  124. else
  125. {
  126. *curlist = newvar ;
  127. }
  128. tmpvar1 = tmpvar1->suiv;
  129. tmpvar2 = tmpvar2->suiv;
  130. }
  131. }