Debian Codegraph @

packages/seacas/applications/grepos/gp_mapvar.f

raw
1 C Copyright(C) 1999-2020, 2024 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 C=======================================================================
8 subroutine mapvar(nold, nnew, nvar, map, vars, scr)
9 C=======================================================================
10 C --*** MAPVAR *** (GREPOS) Map values from old array to new.
11 C --
12 C --MAPVAR reorders the data in VARS based on the map in MAP
13 C --
14 C --Parameters:
15 C -- NOLD - IN - number of old values,
16 C -- NNEW - IN - number of new values
17 C -- NVAR - IN - the number of variables
18 C -- NVARDM - IN - the row dimension of VARNP
19 C -- MAP - IN - map from new value to old MAP(NEW) = OLD
20 C size is 'nnew'
21 C -- VARS - IN/OUT - the values. On input in old order,
22 C on output in new order
23 C -- SCR - TMP - temporary storage area
24
25 integer map(*)
26 real vars(*)
27 c real vars(nold, nvar)
28 real scr(*)
29 logical isseq
30
31 C ... VARS should really be a doubly-dimensioned array (NOLD, NVAR),
32 C The dimensions need to be in this order so we can read them
33 C in using exgnv. But, this order doesn't work very
34 C well when trying to reduce the size of NOLD
35
36 isseq = .false.
37 if (nold .eq. nnew) then
38 isseq = .true.
39 do i=1, nnew
40 if (map(i) .ne. i) then
41 isseq = .false.
42 end if
43 end do
44 end if
45
46 if (isseq) then
47 return
48 end if
49
50 do 30 ivar = 1, nvar
51 do 10 i = 1, nnew
52 scr(i) = vars(map(i) + nold * (ivar-1) )
53 10 continue
54
55 do 20 i = 1, nnew
56 vars(i + nnew * (ivar-1)) = scr(i)
57 20 continue
58 30 continue
59
60 return
61 end