| 1 |
jmc |
1.2 |
C $Header: /u/gcmpack/MITgcm/pkg/mdsio/mdsio_pass_r4tors.F,v 1.1 2009/05/11 02:20:49 jmc Exp $ |
| 2 |
jmc |
1.1 |
C $Name: $ |
| 3 |
|
|
|
| 4 |
|
|
#include "MDSIO_OPTIONS.h" |
| 5 |
|
|
|
| 6 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 7 |
|
|
C- modification: no need to edit the 4 scr files mdsio_pass_r{4,8}tor{l,s}.F : |
| 8 |
|
|
C from the 1rst src file (mdsio_pass_r4torl.F), can update the 3 others |
| 9 |
|
|
C using the script "derive_other_types". |
| 10 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 11 |
|
|
|
| 12 |
|
|
CBOP |
| 13 |
|
|
C !ROUTINE: MDS_PASS_R4toRS |
| 14 |
|
|
C !INTERFACE: |
| 15 |
jmc |
1.2 |
SUBROUTINE MDS_PASS_R4toRS( local, arr, k, nNz, |
| 16 |
|
|
I biArg, bjArg, copyTo, myThid ) |
| 17 |
jmc |
1.1 |
|
| 18 |
|
|
C !DESCRIPTION: |
| 19 |
jmc |
1.2 |
C Transfert 2-D real*4 array to 3-D RS array, or the reverse, |
| 20 |
|
|
C depending on "copyTo" value. Apply transfert to tile biArg,bjArg |
| 21 |
|
|
C only or to all myThid tiles if called with biArg=bjArg=0. |
| 22 |
jmc |
1.1 |
|
| 23 |
|
|
C !USES: |
| 24 |
|
|
IMPLICIT NONE |
| 25 |
|
|
|
| 26 |
|
|
C Global variables / common blocks |
| 27 |
|
|
#include "EEPARAMS.h" |
| 28 |
|
|
#include "SIZE.h" |
| 29 |
|
|
|
| 30 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
| 31 |
|
|
C Routine arguments |
| 32 |
|
|
C local (real*4) :: local 2-D array (Input/Output if copyTo=T/F) |
| 33 |
|
|
C arr ( RS ) :: model 3-D tiled array (Output/Input if copyTo=T/F) |
| 34 |
jmc |
1.2 |
C k (integer):: level index to - fill in / extract from - 3-D array |
| 35 |
jmc |
1.1 |
C nNz (integer):: size of third dimension of 3-D array "arr" |
| 36 |
jmc |
1.2 |
C biArg (integer):: tile X-index to - fill in / extract from - tiled array |
| 37 |
|
|
C bjArg (integer):: tile Y-index to - fill in / extract from - tiled array |
| 38 |
jmc |
1.1 |
C copyTo (logical):: if =T, copy 2-D -> 3-D ; if =F: copy 2-D <- 3-D |
| 39 |
|
|
C myThid (integer):: my Thread Id number |
| 40 |
|
|
INTEGER nNz |
| 41 |
|
|
Real*4 local(1:sNx,1:sNy,nSx,nSy) |
| 42 |
|
|
_RS arr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nNz,nSx,nSy) |
| 43 |
|
|
INTEGER k |
| 44 |
jmc |
1.2 |
INTEGER biArg |
| 45 |
|
|
INTEGER bjArg |
| 46 |
jmc |
1.1 |
LOGICAL copyTo |
| 47 |
|
|
INTEGER myThid |
| 48 |
|
|
|
| 49 |
|
|
C !LOCAL VARIABLES: |
| 50 |
|
|
C i,j :: loop indices |
| 51 |
|
|
C bi,bj :: tile indices |
| 52 |
|
|
INTEGER i,j,bi,bj |
| 53 |
|
|
CEOP |
| 54 |
|
|
|
| 55 |
jmc |
1.2 |
IF ( biArg.EQ.0 .AND. bjArg.EQ.0 ) THEN |
| 56 |
|
|
IF ( copyTo ) THEN |
| 57 |
|
|
DO bj = myByLo(myThid), myByHi(myThid) |
| 58 |
|
|
DO bi = myBxLo(myThid), myBxHi(myThid) |
| 59 |
|
|
DO j=1,sNy |
| 60 |
|
|
DO i=1,sNx |
| 61 |
|
|
arr(i,j,k,bi,bj) = local(i,j,bi,bj) |
| 62 |
|
|
ENDDO |
| 63 |
|
|
ENDDO |
| 64 |
|
|
ENDDO |
| 65 |
|
|
ENDDO |
| 66 |
|
|
ELSE |
| 67 |
|
|
DO bj = myByLo(myThid), myByHi(myThid) |
| 68 |
|
|
DO bi = myBxLo(myThid), myBxHi(myThid) |
| 69 |
|
|
DO j=1,sNy |
| 70 |
|
|
DO i=1,sNx |
| 71 |
|
|
local(i,j,bi,bj) = arr(i,j,k,bi,bj) |
| 72 |
|
|
ENDDO |
| 73 |
|
|
ENDDO |
| 74 |
|
|
ENDDO |
| 75 |
|
|
ENDDO |
| 76 |
|
|
ENDIF |
| 77 |
|
|
ELSEIF ( biArg.GE.1 .AND. biArg.LE.nSx |
| 78 |
|
|
& .AND. bjArg.GE.1 .AND. bjArg.LE.nSy ) THEN |
| 79 |
|
|
bi = biArg |
| 80 |
|
|
bj = bjArg |
| 81 |
|
|
IF ( copyTo ) THEN |
| 82 |
jmc |
1.1 |
DO j=1,sNy |
| 83 |
|
|
DO i=1,sNx |
| 84 |
jmc |
1.2 |
arr(i,j,k,bi,bj) = local(i,j,1,1) |
| 85 |
jmc |
1.1 |
ENDDO |
| 86 |
|
|
ENDDO |
| 87 |
jmc |
1.2 |
ELSE |
| 88 |
jmc |
1.1 |
DO j=1,sNy |
| 89 |
|
|
DO i=1,sNx |
| 90 |
jmc |
1.2 |
local(i,j,1,1) = arr(i,j,k,bi,bj) |
| 91 |
jmc |
1.1 |
ENDDO |
| 92 |
|
|
ENDDO |
| 93 |
jmc |
1.2 |
ENDIF |
| 94 |
|
|
ELSE |
| 95 |
|
|
STOP 'ABNORMAL END: MDS_PASS_R4toRS invalid bi,bj Arg' |
| 96 |
jmc |
1.1 |
ENDIF |
| 97 |
|
|
|
| 98 |
|
|
RETURN |
| 99 |
|
|
END |