OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
my_orders.c
Go to the documentation of this file.
1//Copyright> OpenRadioss
2//Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3//Copyright>
4//Copyright> This program is free software: you can redistribute it and/or modify
5//Copyright> it under the terms of the GNU Affero General Public License as published by
6//Copyright> the Free Software Foundation, either version 3 of the License, or
7//Copyright> (at your option) any later version.
8//Copyright>
9//Copyright> This program is distributed in the hope that it will be useful,
10//Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11//Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12//Copyright> GNU Affero General Public License for more details.
13//Copyright>
14//Copyright> You should have received a copy of the GNU Affero General Public License
15//Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16//Copyright>
17//Copyright>
18//Copyright> Commercial Alternative: Altair Radioss Software
19//Copyright>
20//Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21//Copyright> software under a commercial license. Contact Altair to discuss further if the
22//Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23#include <stdio.h>
24#include <stdlib.h>
25
26#define _FCALL
27
28void tri_direct(unsigned *data,unsigned *iwork, unsigned *index,int n,int irecl,unsigned *inds)
29{
30 /* tri a adressage direct */
31 /* 0 <= x <= 2^16 - 1 */
32
33 unsigned range=65535,mask=0xffff;
34 int i,j,k;
35
36 for(k=irecl-1;k >= 0;k--){
37
38 /* poid faible (16bits)*/
39 for(i = 0 ;i < range+2 ; i++) iwork[i] = 0 ;
40 for(i = 0 ;i < n ; i++){
41 iwork[(data[irecl*index[i]+k] & mask) + 1] += 1 ;
42 }
43 for(i = 0 ;i < range ; i++) iwork[i+1] += iwork[i];
44 for(i = 0 ;i < n ; i++){
45 j = data[irecl*index[i]+k] & mask;
46 inds[iwork[j]] = index[i] ;
47 iwork[j] += 1;
48 }
49
50 /* poid fort (16bits)*/
51 for(i = 0 ;i < range+2 ; i++) iwork[i] = 0 ;
52 for(i = 0 ;i < n ; i++) {
53 iwork[((data[irecl*inds[i]+k] >> 16) & mask) + 1] += 1 ;
54 }
55 for(i = 0 ;i < range ; i++) iwork[i+1] += iwork[i];
56 for(i = 0 ;i < n ; i++){
57 j = (data[irecl*inds[i]+k] >> 16) & mask;
58 index[iwork[j]] = inds[i] ;
59 iwork[j] += 1;
60 }
61 }
62
63}
64void my_orders_(int *mode,unsigned *iwork,unsigned *data,unsigned *index,int *n,int *irecl)
65{
66 int i;
67 if(*mode == 0){
68 for(i = 0 ;i < *n ; i++) index[i] = i ;
69 tri_direct(data,iwork,index,*n,*irecl,index+*n);
70 for(i = 0 ;i < *n ; i++) index[i] += 1 ;/* c => fortran */
71 } else if(*mode == 10){
72 for(i = 0 ;i < *n ; i++) index[i] -= 1 ;
73 tri_direct(data,iwork,index,*n,*irecl,index+*n);
74 for(i = 0 ;i < *n ; i++) index[i] += 1 ;/* c => fortran */
75 } else {
76 *mode = -1;
77 }
78}
79void _FCALL MY_ORDERS(int *mode,int *iwork,int *data,int *index,int *n,int *irecl)
80{my_orders_(mode,(unsigned*)iwork,(unsigned*)data,(unsigned*)index,n,irecl);}
81
82void my_orders(int *mode,int *iwork,int *data,int *index,int *n,int *irecl)
83{my_orders_(mode,(unsigned*)iwork,(unsigned*)data,(unsigned*)index,n,irecl);}
84
85void my_orders__(int *mode,int *iwork,int *data,int *index,int *n,int *irecl)
86{my_orders_(mode,(unsigned*)iwork,(unsigned*)data,(unsigned*)index,n,irecl);}
87
#define _FCALL
void my_orders__(int *mode, int *iwork, int *data, int *index, int *n, int *irecl)
Definition my_orders.c:85
void my_orders(int *mode, int *iwork, int *data, int *index, int *n, int *irecl)
Definition my_orders.c:82
void _FCALL MY_ORDERS(int *mode, int *iwork, int *data, int *index, int *n, int *irecl)
Definition my_orders.c:79
void tri_direct(unsigned *data, unsigned *iwork, unsigned *index, int n, int irecl, unsigned *inds)
Definition my_orders.c:28
void my_orders_(int *mode, unsigned *iwork, unsigned *data, unsigned *index, int *n, int *irecl)
Definition my_orders.c:64
n