@@ -26,7 +26,7 @@ MODULE AWAE_IO
2626 use NWTC_Library
2727 use VTK
2828 use AWAE_Types
29-
29+ use iso_c_binding, only: c_char, c_int, c_double, c_float, c_null_char
3030
3131 implicit none
3232
@@ -35,6 +35,23 @@ MODULE AWAE_IO
3535
3636 public :: AWAE_IO_InitGridInfo
3737 public :: ReadLowResWindFile
38+
39+ interface
40+ subroutine ReadVTK_inflow_info (FileName , Desc , dims , origin , gridSpacing , vecLabel , values , read_values , err_stat , err_msg ) BIND(C,name= ' ReadVTK_inflow_info' )
41+ use iso_c_binding, only: c_char, c_int, c_double, c_float, c_null_char
42+ implicit none
43+ character (kind= c_char), intent (in ) :: FileName(* )
44+ character (kind= c_char), intent (out ) :: Desc(1024 )
45+ integer (c_int), intent (out ) :: dims(3 )
46+ real (c_double), intent (out ) :: origin(3 )
47+ real (c_double), intent (out ) :: gridSpacing(3 )
48+ character (kind= c_char), intent (out ) :: vecLabel(1024 )
49+ real (c_float), intent (out ) :: values(* )
50+ integer (c_int), intent (in ) :: read_values
51+ integer (c_int), intent (out ) :: err_stat
52+ character (kind= c_char), intent (out ) :: err_msg(1024 )
53+ end subroutine
54+ end interface
3855
3956 contains
4057
@@ -91,26 +108,24 @@ end subroutine WriteDisWindFiles
91108subroutine ReadLowResWindFile (n , p , Vamb_Low , errStat , errMsg )
92109 integer (IntKi), intent (in ) :: n ! < Current simulation timestep increment (zero-based)
93110 type (AWAE_ParameterType), intent (in ) :: p ! < Parameters
94- real (SiKi), intent (inout ) :: Vamb_Low(:,0 :,0 :,0 :) ! < Array which will contain the low resolution grid of ambient wind velocities
111+ real (SiKi), contiguous, intent (inout ) :: Vamb_Low(:,0 :,0 :,0 :) ! < Array which will contain the low resolution grid of ambient wind velocities
95112 integer (IntKi), intent ( out ) :: errStat ! < Error status of the operation
96113 character (* ), intent ( out ) :: errMsg ! < Error message if errStat /= ErrID_None
97114
98- integer (IntKi) :: dims(3 ) ! dimension of the 3D grid (nX,nY,nZ)
99- real (ReKi) :: origin(3 ) ! the lower-left corner of the 3D grid (X0,Y0,Z0)
100- real (ReKi) :: gridSpacing(3 ) ! spacing between grid points in each of the 3 directions (dX,dY,dZ)
101- integer (IntKi) :: Un ! unit number of opened file
102- character (1024 ) :: FileName ! Name of output file
103- character (1024 ) :: desc ! Line describing the contents of the file
104- character (1024 ) :: vecLabel ! descriptor of the vector data
115+ integer (IntKi) :: dims(3 ) ! Dimension of the 3D grid (nX,nY,nZ)
116+ real (R8 Ki) :: origin(3 ) ! The lower-left corner of the 3D grid (X0,Y0,Z0)
117+ real (R8 Ki) :: gridSpacing(3 ) ! Spacing between grid points in each of the 3 directions (dX,dY,dZ)
118+ character (kind= c_char) :: FileName(2048 ) ! Name of output file
119+ character (kind= c_char) :: desc(1024 ) ! Line describing the contents of the file
120+ character (kind= c_char) :: vecLabel(1024 ) ! descriptor of the vector data
105121
106122 errStat = ErrID_None
107123 errMsg = " "
108124
109- FileName = trim (p% WindFilePath)// trim (PathSep)// " Low" // trim (PathSep)// " Amb.t" // trim (Num2LStr(n))// " .vtk"
110- Un = 0 ; ! Initialization different from -1, important to prevent file closing
111- call ReadVTK_SP_info(FileName, desc, dims, origin, gridSpacing, vecLabel, Un, ErrStat, ErrMsg)
112- if (ErrStat >= AbortErrLev) return
113- call ReadVTK_SP_vectors(FileName, Un, dims, Vamb_Low, ErrStat, ErrMsg)
125+ FileName = transfer (trim (p% WindFilePath)// trim (PathSep)// " Low" // trim (PathSep)// " Amb.t" // trim (Num2LStr(n))// " .vtk" // c_null_char, FileName)
126+ call ReadVTK_inflow_info(FileName, desc, dims, origin, gridSpacing, vecLabel, Vamb_Low, 1 , ErrStat, ErrMsg)
127+ if (ErrStat /= ErrID_None) ErrMsg = " ReadLowResWindFile:" // trim (ErrMsg)
128+
114129end subroutine ReadLowResWindFile
115130
116131!- ---------------------------------------------------------------------------------------------------------------------------------
@@ -120,28 +135,24 @@ subroutine ReadHighResWindFile(nt, n, p, Vamb_high, errStat, errMsg)
120135 integer (IntKi), intent (in ) :: nt
121136 integer (IntKi), intent (in ) :: n ! < high-res time increment
122137 type (AWAE_ParameterType), intent (in ) :: p ! < Parameters
123- real (SiKi), intent (inout ) :: Vamb_high(:,0 :,0 :,0 :) ! < Array which will contain the low resolution grid of ambient wind velocities
138+ real (SiKi), contiguous, intent (inout ) :: Vamb_high(:,0 :,0 :,0 :) ! < Array which will contain the low resolution grid of ambient wind velocities
124139 integer (IntKi), intent ( out ) :: errStat ! < Error status of the operation
125140 character (* ), intent ( out ) :: errMsg ! < Error message if errStat /= ErrID_None
126141
127-
128- integer (IntKi) :: dims(3 ) ! dimension of the 3D grid (nX,nY,nZ)
129- real (ReKi) :: origin(3 ) ! the lower-left corner of the 3D grid (X0,Y0,Z0)
130- real (ReKi) :: gridSpacing(3 ) ! spacing between grid points in each of the 3 directions (dX,dY,dZ)
131- integer (IntKi) :: Un ! unit number of opened file
132- character (1024 ) :: FileName ! Name of output file
133- character (1024 ) :: desc ! Line describing the contents of the file
134- character (1024 ) :: vecLabel ! descriptor of the vector data
142+ integer (IntKi) :: dims(3 ) ! Dimension of the 3D grid (nX,nY,nZ)
143+ real (R8 Ki) :: origin(3 ) ! The lower-left corner of the 3D grid (X0,Y0,Z0)
144+ real (R8 Ki) :: gridSpacing(3 ) ! Spacing between grid points in each of the 3 directions (dX,dY,dZ)
145+ character (kind= c_char) :: FileName(2048 ) ! Name of output file
146+ character (kind= c_char) :: desc(1024 ) ! Line describing the contents of the file
147+ character (kind= c_char) :: vecLabel(1024 ) ! descriptor of the vector data
135148
136149 errStat = ErrID_None
137150 errMsg = " "
138151
139- FileName = trim (p% WindFilePath)// trim (PathSep)// " HighT" // trim (num2lstr(nt))// trim (PathSep)// " Amb.t" // trim (num2lstr(n))// " .vtk"
140- Un = 0 ; ! Initialization different from -1, important to prevent file closing
141- call ReadVTK_SP_info( FileName, desc, dims, origin, gridSpacing, vecLabel, Un, ErrStat, ErrMsg )
142- if (ErrStat >= AbortErrLev) return
143- call ReadVTK_SP_vectors( FileName, Un, dims, Vamb_high, ErrStat, ErrMsg )
144-
152+ FileName = transfer (trim (p% WindFilePath)// trim (PathSep)// " HighT" // trim (num2lstr(nt))// trim (PathSep)// " Amb.t" // trim (num2lstr(n))// " .vtk" // c_null_char, FileName)
153+ call ReadVTK_inflow_info(FileName, desc, dims, origin, gridSpacing, vecLabel, Vamb_high, 1 , ErrStat, ErrMsg)
154+ if (ErrStat /= ErrID_None) ErrMsg = " ReadHighResWindFile:" // trim (ErrMsg)
155+
145156end subroutine ReadHighResWindFile
146157!- ---------------------------------------------------------------------------------------------------------------------------------
147158! > Flat array of Cartesian point coordinates
0 commit comments