Skip to content

Commit

Permalink
Invert string arrays in Fortran
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoonj committed May 13, 2019
1 parent 68fae75 commit e600d82
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/def/shadow_oe.def
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ EXPAND_OE_SCALAR(double,real,skr,T_DOUBLE,DUMMY,"%lf",'(F)',0.0)
EXPAND_OE_ARRAYS(double,real,skr,T_DOUBLE,CX_SLIT,"%lf",'(F)',ADIM,0.0)
EXPAND_OE_ARRAYS(double,real,skr,T_DOUBLE,CZ_SLIT,"%lf",'(F)',ADIM,0.0)
EXPAND_OE_ARRAYS(double,real,skr,T_DOUBLE,D_PLATE,"%lf",'(F)',ADIM,0.0)
EXPAND_OE_ARRSTR(char,character,skc,T_STRING,FILE_ABS,"%s",'(A)',ADIM,STRLEN,"")
EXPAND_OE_ARRSTR(char,character,skc,T_STRING,FILE_SCR_EXT,"%s",'(A)',ADIM,STRLEN,"")
EXPAND_OE_ARRSTR(char,character,skc,T_STRING,FILE_ABS,"%s",'(A)',ADIM,STRLEN,' ')
EXPAND_OE_ARRSTR(char,character,skc,T_STRING,FILE_SCR_EXT,"%s",'(A)',ADIM,STRLEN, ' ')
EXPAND_OE_ARRAYS(int,integer,ski,T_INT,I_ABS,"%d",'(I)',ADIM,0)
EXPAND_OE_ARRAYS(int,integer,ski,T_INT,I_SCREEN,"%d",'(I)',ADIM,0)
EXPAND_OE_ARRAYS(int,integer,ski,T_INT,I_SLIT,"%d",'(I)',ADIM,0)
Expand Down
8 changes: 4 additions & 4 deletions src/fortran/gfile.f90
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ function GfGetArrayValueString(g1,varname,varval) result(iOut)
character(kind=skc, len=sklen) :: tempString

iOut = .true.
do i=1,size(varval, dim=1)
do i=1,size(varval, dim=2)
write(f,'(I2)') i
iOut = GfGetValueString(g1,TRIM(varname)//"("//trim(adjustl(f))//")",varval(i,:)) .and. iOut
iOut = GfGetValueString(g1,TRIM(varname)//"("//trim(adjustl(f))//")",varval(:,i)) .and. iOut
end do
end function

Expand Down Expand Up @@ -153,9 +153,9 @@ function GfSetArrayValueString(g1,varname,varval) result(iOut)
character(len=5) :: f

iOut = .true.
do i=1,size(varval, dim=1)
do i=1,size(varval, dim=2)
write(f,'(I2)') i
iOut = GfForceSetValueString(g1,TRIM(varname)//"("//trim(adjustl(f))//")",varval(i,:)) .and. iOut
iOut = GfForceSetValueString(g1,TRIM(varname)//"("//trim(adjustl(f))//")",varval(:,i)) .and. iOut
end do
end function

Expand Down
14 changes: 7 additions & 7 deletions src/fortran/shadow_kernel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Module shadow_kernel
#define EXPAND_OE_SCALAR(ctype,ftype,fkind,pytype,name,cformat,fformat,defvalue) ftype(kind=fkind) :: name
#define EXPAND_OE_STRING(ctype,ftype,fkind,pytype,name,cformat,fformat,length,defvalue) ftype(kind=fkind,len=1), dimension(length) :: name
#define EXPAND_OE_ARRAYS(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,defvalue) ftype(kind=fkind), dimension(arrdim) :: name
#define EXPAND_OE_ARRSTR(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,length,defvalue) ftype(kind=fkind, len=1), dimension(arrdim, length) :: name
#define EXPAND_OE_ARRSTR(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,length,defvalue) ftype(kind=fkind, len=1), dimension(length, arrdim) :: name
#include "shadow_oe_without_repetitions.def"


Expand Down Expand Up @@ -5290,8 +5290,8 @@ SUBROUTINE RESET
K_SLIT(I) = 0
I_STOP(I) = 0
I_ABS(I) = 0
FILE_ABS(I,:) = GfConvertStringToStringArr('NONE SPECIFIED')
FILE_SCR_EXT(I,:) = GfConvertStringToStringArr('NONE SPECIFIED')
FILE_ABS(:,I) = GfConvertStringToStringArr('NONE SPECIFIED')
FILE_SCR_EXT(:,I) = GfConvertStringToStringArr('NONE SPECIFIED')
11 CONTINUE
! C
! C SYSTEM block
Expand Down Expand Up @@ -6098,7 +6098,7 @@ SUBROUTINE SCREEN (RAY,AP_IN,PH_IN,I_WHAT,I_ELEMENT)
FTEMP = F_REFL
F_REFL = 0
FILE_TMP = GfConvertStringArrToString(FILE_REFL)
FILE_REFL = FILE_ABS(I_WHAT,:)
FILE_REFL = FILE_ABS(:,I_WHAT)
tmp = THICK(I_WHAT) * user_units_to_cm
CALL REFLEC (ppout,DUM,DUM,DUM,DUM,DUM,DUM,DUM,tmp,izero)
END IF
Expand Down Expand Up @@ -6361,7 +6361,7 @@ SUBROUTINE SCREEN_EXTERNAL(I_SCR,I_ELEMENT,RAY,RAY_OUT)
! C indices (into xvec and zvec) and number of points per polygon.
! C
IFLAG = 0
filename = GfConvertStringArrToString(FILE_SCR_EXT(I_SCR,:))
filename = GfConvertStringArrToString(FILE_SCR_EXT(:,I_SCR))
CALL SCREEN_EXTERNAL_GETDIMENSIONS(filename, N_POLYS,N_POINTS,IFLAG)
!print *,'>>> SCREEN_EXTERNAL_GETDIMENSIONS: N_POLYS: ',N_POLYS
!print *,'>>> SCREEN_EXTERNAL_GETDIMENSIONS: N_POINTS: ',N_POINTS
Expand Down Expand Up @@ -10339,7 +10339,7 @@ SUBROUTINE INPUT_OE (I_OENUM,iTerminate)
K_SLIT(I) = IRINT ('Stop shape [ 0 r, 1 e, 2 ex ] ? ')
IF (K_SLIT(I).EQ.2) THEN
! XXFILSCR(I) = RSTRING('File containing the mask coordinates ? ')
FILE_SCR_EXT(I,:) = GfConvertStringToStringArr(RSTRING('File containing the mask coordinates ? '))
FILE_SCR_EXT(:,I) = GfConvertStringToStringArr(RSTRING('File containing the mask coordinates ? '))
ELSE
RX_SLIT(I)= RNUMBER ('Dimension along X ? ')
RZ_SLIT(I)= RNUMBER (' Z ? ')
Expand All @@ -10352,7 +10352,7 @@ SUBROUTINE INPUT_OE (I_OENUM,iTerminate)
IF (I_ABS(I).EQ.1) THEN
WRITE(6,*) 'File with optical constants ?'
READ (5,111) TEXT
FILE_ABS(I,:) = GfConvertStringToStringArr(TEXT)
FILE_ABS(:,I) = GfConvertStringToStringArr(TEXT)
THICK(I) = RNUMBER ('Thickness of film [ cm ] ? ')
END IF
11 CONTINUE
Expand Down
6 changes: 3 additions & 3 deletions src/fortran/shadow_variables.f90
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Module shadow_variables
#define EXPAND_OE_SCALAR(ctype,ftype,fkind,pytype,name,cformat,fformat,defvalue) ftype(kind=fkind) :: name
#define EXPAND_OE_STRING(ctype,ftype,fkind,pytype,name,cformat,fformat,length,defvalue) ftype(kind=fkind,len=1), dimension(length) :: name
#define EXPAND_OE_ARRAYS(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,defvalue) ftype(kind=fkind), dimension(arrdim) :: name
#define EXPAND_OE_ARRSTR(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,length,defvalue) ftype(kind=fkind, len=1), dimension(arrdim,length) :: name
#define EXPAND_OE_ARRSTR(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,length,defvalue) ftype(kind=fkind, len=1), dimension(length,arrdim) :: name
#include "shadow_oe.def"
end type poolOE

Expand Down Expand Up @@ -302,8 +302,8 @@ subroutine PoolOEDefault(oe)
integer(kind=ski) :: i, j
#define EXPAND_OE_SCALAR(ctype,ftype,fkind,pytype,name,cformat,fformat,defvalue) oe%name=defvalue
#define EXPAND_OE_STRING(ctype,ftype,fkind,pytype,name,cformat,fformat,length,defvalue) oe%name=defvalue
#define EXPAND_OE_ARRAYS(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,defvalue) FORALL(i=1:arrdim) oe%name(i)=defvalue
#define EXPAND_OE_ARRSTR(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,length,defvalue) FORALL(i=1:arrdim, j=1:length) oe%name(i,j)=defvalue
#define EXPAND_OE_ARRAYS(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,defvalue) oe%name=defvalue
#define EXPAND_OE_ARRSTR(ctype,ftype,fkind,pytype,name,cformat,fformat,arrdim,length,defvalue) oe%name=defvalue
#include "shadow_oe.def"
end subroutine PoolOEDefault

Expand Down

0 comments on commit e600d82

Please sign in to comment.