Skip to content

Commit

Permalink
Merge pull request #3 from Mohid-Water-Modelling-System/master
Browse files Browse the repository at this point in the history
Fork_Update
  • Loading branch information
campuzanofj authored Aug 2, 2022
2 parents bda807c + d0672ca commit 4447f54
Show file tree
Hide file tree
Showing 63 changed files with 17,390 additions and 5,426 deletions.
Binary file added ExternalLibs/HDF5_1.8.17_x64/Lib/display.txt
Binary file not shown.
3 changes: 3 additions & 0 deletions Samples/Offline_Upscaling_Discharge/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a ready to use offline upscaling where only discharges are included (no nudging of the solution).
This type of simulation is useful for when local estuarine model results need to be upscaled to a regional domain,
and when the user only wants to transfer the tidal fluxes from local to regional domain.
Binary file not shown.
Binary file not shown.
19 changes: 17 additions & 2 deletions Software/ConvertHDF5ToGridData/ConvertHDF5ToGridData.f90
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,15 @@ subroutine ConvertHDF5ToGridData
Rank = GroupRank, &
Dimensions = Dimensions, &
STAT = STAT_CALL)
if (STAT_CALL .NE. SUCCESS_) &
stop 'ConvertToGridData - HDF5ToGridData - ERR50'
if (GroupRank==-1) then
call GetHDF5ArrayDimensions (HDF5ID = ObjHDF5, &
GroupName = trim(HDFGroup), &
ItemName = trim(Property), &
NDim = GroupRank, &
Imax = Dimensions(1), &
Jmax = Dimensions(2))
write(*,*) 'ConvertToGridData - HDF5ToGridData - WRN50'
endif

select case (GroupRank)

Expand Down Expand Up @@ -392,11 +399,19 @@ subroutine Convert2DField (Dimensions, HDFGroup, Property)

else
!one defined instant
if (Instant > 0) then
call HDF5ReadData (ObjHDF5, trim(HDFGroup), &
trim(Property), &
Array2D = PropertyField, &
OutputNumber = Instant, STAT = STAT_CALL)
if (STAT_CALL /= SUCCESS_) stop 'ConvertToGridData - HDF5ToGridData - ERR90'
else
call HDF5ReadData (ObjHDF5, trim(HDFGroup), &
trim(Property), &
Array2D = PropertyField, &
STAT = STAT_CALL)
if (STAT_CALL /= SUCCESS_) stop 'ConvertToGridData - HDF5ToGridData - ERR100'
endif

call ConstructDSName(Property,Instant,AuxChar)
Output = trim(AuxChar) // ".dat"
Expand Down
9 changes: 8 additions & 1 deletion Software/ConvertToHDF5/ConvertToHDF5.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ program ConvertToHDF5
use ModuleInterpolateTime
use ModuleGlueHDF5Files
use ModulePatchHDF5Files
use ModuleUpscaleHDF5
#ifndef _NO_NETCDF
use ModuleCFFormat
use ModuleCFPolcomFormat
Expand Down Expand Up @@ -109,6 +110,7 @@ program ConvertToHDF5
character(len = StringLength), parameter:: InterpolateTime = 'INTERPOLATE TIME'
character(len = StringLength), parameter:: GluesHD5Files = 'GLUES HDF5 FILES'
character(len = StringLength), parameter:: PatchHD5Files = 'PATCH HDF5 FILES'
character(len = StringLength), parameter:: UpscaleHDF5 = 'UPSCALE HDF5 FILES'
character(len = StringLength), parameter:: ConvertIHRadarFormatToHDF5 = 'CONVERT IH RADAR FORMAT'

character(len = StringLength), parameter:: ConvertDelft3DFormatToHDF5 = 'CONVERT DELFT3D FORMAT'
Expand Down Expand Up @@ -531,8 +533,13 @@ subroutine ReadOptions

case (ConvertDelft3DFormatToHDF5)

call ConvertDelft3D_2_Mohid(ObjEnterData, ClientNumber, STAT = STAT_CALL)
call ConvertDelft3D_2_Mohid(ObjEnterData, ClientNumber, STAT = STAT_CALL)

case (UpscaleHDF5)

call StartUpscaleHDF5(ObjEnterData, ClientNumber, STAT = STAT_CALL)
if(STAT_CALL .ne. SUCCESS_) stop 'ReadOptions - ConvertToHDF5 - ERR270'

case default

stop 'Option not known - ReadOptions - ConvertToHDF5 - ERR299'
Expand Down
71 changes: 38 additions & 33 deletions Software/ConvertToHDF5/ModuleCALMETFormat.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Module ModuleCALMETFormat
use ModuleTime
use ModuleGridData
use ModuleHorizontalGrid
use proj4
use fproj

implicit none

Expand Down Expand Up @@ -125,8 +125,8 @@ Module ModuleCALMETFormat
real :: XOri, YOri = null_real
real :: DX, DY

type(prj90_projection) :: Proj
character(len=20), dimension(8) :: Params
type(fproj_prj) :: Proj
character(256) :: Params



Expand Down Expand Up @@ -348,7 +348,7 @@ subroutine OpenAndReadTerrainFile
integer :: ILB,IUB, WILB, WIUB
integer :: JLB,JUB, WJLB, WJUB
real, pointer, dimension(:,:) :: DataAux

character(256) :: a1,a2,a3,a4,a5,a6,a7
!Begin-----------------------------------------------------------------


Expand Down Expand Up @@ -418,28 +418,28 @@ subroutine OpenAndReadTerrainFile
call ConvertLatLonCharToReal(Clon0, Me%CenterLon)
call ConvertLatLonCharToReal(Csp1, Me%TrueLatLower)
call ConvertLatLonCharToReal(Csp2, Me%TrueLatUpper)


Me%Params(1) = 'proj=lcc'
Me%Params(2) = 'ellps=WGS84'
write(Me%Params(3),'(a6,f8.3)') 'lat_1=', Me%TrueLatLower
write(Me%Params(4),'(a6,f8.3)') 'lat_2=', Me%TrueLatUpper
write(Me%Params(5),'(a6,f8.3)') 'lon_0=', Me%CenterLon
write(Me%Params(6),'(a6,f8.3)') 'lat_0=', Me%CenterLat
write(Me%Params(7),'(a4,f12.3)') 'x_0=' , Me%FalseEast
write(Me%Params(8),'(a4,f12.3)') 'y_0=' , Me%FalseNorth


a1 = '+proj=lcc +ellps=WGS84'
write(a2,'(a7,f8.3)') '+lat_1=', Me%TrueLatLower
write(a3,'(a7,f8.3)') '+lat_2=', Me%TrueLatUpper
write(a4,'(a7,f8.3)') '+lon_0=', Me%CenterLon
write(a5,'(a7,f8.3)') '+lat_0=', Me%CenterLat
write(a6,'(a5,f12.3)') '+x_0=', Me%FalseEast
write(a7,'(a5,f12.3)') '+y_0=', Me%FalseNorth

write(Me%Params, '(7(a,1x))') trim(a1), trim(a2), trim(a3), trim(a4), trim(a5), trim(a6), trim(a7)


else
stop 'Not ready for projections other than LCC'
endif


write(*,*) Me%Params

STAT_CALL = prj90_init(Me%Proj,Me%Params)
STAT_CALL = fproj_init(Me%Proj,Me%Params)
call handle_proj_error(STAT_CALL)
if (STAT_CALL /= PRJ90_NOERR) stop 'OpenReadWriteTerrainFile - ModuleCALMETFormat - ERR04'
if (STAT_CALL /= FPROJ_NOERR) stop 'OpenReadWriteTerrainFile - ModuleCALMETFormat - ERR04'

!Read terrain -------------------------------------

Expand Down Expand Up @@ -500,9 +500,9 @@ subroutine WriteGridInformation
x = dble(Me%XOri + (j-1)*Me%DX)
y = dble(Me%YOri + (i-1)*Me%DY)

STAT_CALL = prj90_inv(Me%Proj, x, y, lon, lat)
STAT_CALL = fproj_inv(Me%Proj, x, y, lon, lat)
call handle_proj_error(STAT_CALL)
if (STAT_CALL /= PRJ90_NOERR) stop 'WriteGridInformation - ModuleCALMETFormat - ERR01'
if (STAT_CALL /= FPROJ_NOERR) stop 'WriteGridInformation - ModuleCALMETFormat - ERR01'

Me%ConnectionX(i,j) = lon
Me%ConnectionY(i,j) = lat
Expand All @@ -517,9 +517,9 @@ subroutine WriteGridInformation
x = dble(Me%XOri + Me%DX/2. + (j-1)*Me%DX)
y = dble(Me%YOri + Me%DY/2. + (i-1)*Me%DY)

STAT_CALL = prj90_inv(Me%Proj, x, y, lon, lat)
STAT_CALL = fproj_inv(Me%Proj, x, y, lon, lat)
call handle_proj_error(STAT_CALL)
if (STAT_CALL /= PRJ90_NOERR) stop 'WriteGridInformation - ModuleCALMETFormat - ERR02'
if (STAT_CALL /= FPROJ_NOERR) stop 'WriteGridInformation - ModuleCALMETFormat - ERR02'

Me%CenterX(i,j) = lon
Me%CenterY(i,j) = lat
Expand Down Expand Up @@ -833,6 +833,8 @@ subroutine OpenAndReadCALMETFile
real,pointer, dimension(:) :: DataAux1D
real,pointer, dimension(:,:,:) :: DataAux3D1, DataAux3D2, DataAux3D3
character(len=StringLength) :: MohidName, Units
character(256) :: a1,a2,a3,a4,a5,a6,a7


!Begin-----------------------------------------------------------------

Expand Down Expand Up @@ -930,16 +932,19 @@ subroutine OpenAndReadCALMETFile
Me%CenterLon = relon0
Me%TrueLatLower = xlat1
Me%TrueLatUpper = xlat2

Me%Params(1) = 'proj=lcc'
Me%Params(2) = 'ellps=WGS84'
write(Me%Params(3),'(a6,f8.3)') 'lat_1=', Me%TrueLatLower
write(Me%Params(4),'(a6,f8.3)') 'lat_2=', Me%TrueLatUpper
write(Me%Params(5),'(a6,f8.3)') 'lon_0=', Me%CenterLon
write(Me%Params(6),'(a6,f8.3)') 'lat_0=', Me%CenterLat
write(Me%Params(7),'(a4,f12.3)') 'x_0=' , Me%FalseEast
write(Me%Params(8),'(a4,f12.3)') 'y_0=' , Me%FalseNorth


a1 = '+proj=lcc +ellps=WGS84'
write(a2,'(a7,f8.3)') '+lat_1=', Me%TrueLatLower
write(a3,'(a7,f8.3)') '+lat_2=', Me%TrueLatUpper
write(a4,'(a7,f8.3)') '+lon_0=', Me%CenterLon
write(a5,'(a7,f8.3)') '+lat_0=', Me%CenterLat
write(a6,'(a5,f12.3)') '+x_0=', Me%FalseEast
write(a7,'(a5,f12.3)') '+y_0=', Me%FalseNorth

write(Me%Params, '(7(a,1x))') trim(a1), trim(a2), trim(a3), trim(a4), trim(a5), trim(a6), trim(a7)


else
write(*,*) 'Map Projection = ', trim(adjustl(pmap))
write(*,*) 'Not ready for projections other than LCC'
Expand All @@ -948,9 +953,9 @@ subroutine OpenAndReadCALMETFile

write(*,*) Me%Params

STAT_CALL = prj90_init(Me%Proj,Me%Params)
STAT_CALL = fproj_init(Me%Proj,Me%Params)
call handle_proj_error(STAT_CALL);
if (STAT_CALL /= PRJ90_NOERR) stop 'OpenAndReadCALMETFile - ModuleCALMETFormat - ERR05'
if (STAT_CALL /= FPROJ_NOERR) stop 'OpenAndReadCALMETFile - ModuleCALMETFormat - ERR05'

else ! ConvertTERRAIN = TRUE, check that parameters are the same

Expand Down Expand Up @@ -2189,7 +2194,7 @@ subroutine handle_proj_error (status)

integer, intent(in) :: status

if (status /= PRJ90_NOERR) write(*,*) trim(prj90_strerrno(status))
if (status /= FPROJ_NOERR) write(*,*) trim(fproj_strerrno(status))

end subroutine handle_proj_error

Expand Down
5 changes: 3 additions & 2 deletions Software/ConvertToHDF5/ModuleGlueHDF5Files.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1745,10 +1745,11 @@ recursive subroutine GlueInResults (ObjHDF5_Out, IDOut, IDIn, GroupName, FirstIn
integer(HID_T) :: gr_idIn, gr_idOut
integer(HID_T) :: dset_id, gr_id
integer(HID_T) :: space_id
integer(HID_T) :: STAT_CALL
character(StringLength) :: NewGroupName
integer(HSIZE_T), dimension(7) :: dims, maxdims
integer, dimension(7) :: dims_int
integer :: Rank, STAT_CALL, k, ia
integer :: Rank, k, ia
real, pointer, dimension(:) :: DataVal1D
real, pointer, dimension(:,:) :: DataVal2D
integer, pointer, dimension(:,:) :: DataInt2D
Expand Down Expand Up @@ -1884,7 +1885,7 @@ recursive subroutine GlueInResults (ObjHDF5_Out, IDOut, IDIn, GroupName, FirstIn
call h5Tcopy_f (H5T_NATIVE_CHARACTER, type_id, STAT_CALL)
if (STAT_CALL /= 0) stop 'GlueInResults - ModuleHDF5Files - ERR140'

call h5Tset_size_f (type_id, StringLength, STAT_CALL)
call h5Tset_size_f (type_id, int(StringLength, 8), STAT_CALL)
if (STAT_CALL /= 0) stop 'GlueInResults - ModuleHDF5Files - ERR150'

call h5aread_f (attr_id, type_id, Units, dims, STAT_CALL)
Expand Down
10 changes: 5 additions & 5 deletions Software/ConvertToHDF5/ModuleIHRadarFormat.F90
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ subroutine ReadOptions
ClientModule = 'ModuleIHRadarFormat', &
STAT = STAT_CALL)
if (STAT_CALL /= SUCCESS_) stop 'ReadOptions - ModuleIHRadarFormat - ERR11'
if (iflag) then
if (iflag == 1) then
Me%OutputHDF5 = .true.
else
Me%OutputHDF5 = .false.
Expand All @@ -288,7 +288,7 @@ subroutine ReadOptions
ClientModule = 'ModuleIHRadarFormat', &
STAT = STAT_CALL)
if (STAT_CALL /= SUCCESS_) stop 'ReadOptions - ModuleIHRadarFormat - ERR12'
if (iflag) then
if (iflag == 1) then
Me%OutputNetcdf = .true.
else
Me%OutputNetcdf = .false.
Expand All @@ -307,7 +307,7 @@ subroutine ReadOptions
ClientModule = 'ModuleIHRadarFormat', &
STAT = STAT_CALL)
if (STAT_CALL /= SUCCESS_) stop 'ReadOptions - ModuleIHRadarFormat - ERR20'
if (.not.iflag) then
if (iflag .ne. 1) then
write(*,*) 'Please define OUTPUT_GRID_FILENAME keyword'
stop 'ReadOptions - ModuleIHRadarFormat - ERR21'
endif
Expand All @@ -320,7 +320,7 @@ subroutine ReadOptions
ClientModule = 'ModuleIHRadarFormat', &
STAT = STAT_CALL)
if (STAT_CALL /= SUCCESS_) stop 'ReadOptions - ModuleIHRadarFormat - ERR80'
if (.not.iflag) then
if (iflag .ne. 1) then
write(*,*) 'Please define INPUT_GRID_FILENAME keyword'
stop 'ReadOptions - ModuleIHRadarFormat - ERR22'
endif
Expand All @@ -332,7 +332,7 @@ subroutine ReadOptions
ClientModule = 'ModuleIHRadarFormat', &
STAT = STAT_CALL)
if (STAT_CALL /= SUCCESS_) stop 'ReadOptions - ModuleIHRadarFormat - ERR81'
if (.not.iflag) then
if (iflag .ne. 1) then
write(*,*) 'Please define IH_GRID_VERSION keyword'
stop 'ReadOptions - ModuleIHRadarFormat - ERR23'
endif
Expand Down
Loading

0 comments on commit 4447f54

Please sign in to comment.