Skip to content

Commit 2c2fd04

Browse files
authored
Merge branch 'develop' into feature/zhaobin74/update-cice6-forcing-nml
2 parents c079073 + 1e77607 commit 2c2fd04

File tree

11 files changed

+7057
-0
lines changed

11 files changed

+7057
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/@ncar_topo/
2+
/ncar_topo/
3+
/ncar_topo@/

GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSsurface_GridComp/Utils/Raster/makebcs/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ else ()
3737
target_compile_definitions(${this} PRIVATE STDC)
3838
endif ()
3939

40+
esma_add_subdirectories (@ncar_topo utils_topo)
41+
4042
ecbuild_add_executable (TARGET CombineRasters.x SOURCES CombineRasters.F90 LIBS MAPL ${this})
4143
ecbuild_add_executable (TARGET mkCatchParam.x SOURCES mkCatchParam.F90 LIBS MAPL ${this} OpenMP::OpenMP_Fortran)
4244
ecbuild_add_executable (TARGET mkCubeFVRaster.x SOURCES mkCubeFVRaster.F90 LIBS MAPL ${this})
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#--------------------
2+
# Copy include files that are used by other libraries.
3+
# We could leave these in the source directory, and just broaden the search path
4+
# in the other libaries, but this make it explicit which aspects are externally
5+
# used.
6+
7+
ecbuild_add_executable (TARGET generate_scrip_cube_topo.x SOURCES generate_scrip_cube.F90 geompack.F90)
8+
target_link_libraries (generate_scrip_cube_topo.x PRIVATE MPI::MPI_Fortran esmf)
9+
# CMake has an OpenMP issue with NAG Fortran: https://gitlab.kitware.com/cmake/cmake/-/issues/21280
10+
if (NOT CMAKE_Fortran_COMPILER_ID MATCHES "NAG")
11+
target_link_libraries(generate_scrip_cube_topo.x PRIVATE OpenMP::OpenMP_Fortran)
12+
endif ()
13+
14+
ecbuild_add_executable (TARGET convert_bin_to_netcdf_topo.x SOURCES convert_bin_to_netcdf.F90)
15+
target_link_libraries (convert_bin_to_netcdf_topo.x PRIVATE MPI::MPI_Fortran NetCDF::NetCDF_Fortran)
16+
# CMake has an OpenMP issue with NAG Fortran: https://gitlab.kitware.com/cmake/cmake/-/issues/21280
17+
if (NOT CMAKE_Fortran_COMPILER_ID MATCHES "NAG")
18+
target_link_libraries(convert_bin_to_netcdf_topo.x PRIVATE OpenMP::OpenMP_Fortran)
19+
endif ()
20+
21+
ecbuild_add_executable (TARGET convert_to_gmao_output_topo.x SOURCES convert_to_gmao_output.F90)
22+
target_link_libraries (convert_to_gmao_output_topo.x PRIVATE MPI::MPI_Fortran NetCDF::NetCDF_Fortran)
23+
# CMake has an OpenMP issue with NAG Fortran: https://gitlab.kitware.com/cmake/cmake/-/issues/21280
24+
if (NOT CMAKE_Fortran_COMPILER_ID MATCHES "NAG")
25+
target_link_libraries(convert_to_gmao_output_topo.x PRIVATE OpenMP::OpenMP_Fortran)
26+
endif ()
27+
28+
install(PROGRAMS scrip_to_cube_topo.py DESTINATION bin)
29+
install(PROGRAMS scrip_to_restart_topo.py DESTINATION bin)
30+
install(PROGRAMS generate_topo.sh DESTINATION bin)
31+
install(PROGRAMS make_topo.py DESTINATION bin)
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
program create_example
2+
use netcdf
3+
use, intrinsic :: iso_fortran_env, only: REAL64
4+
implicit none
5+
6+
7+
character(len=512) :: fin,fout,str,fncar
8+
integer :: im_world,jm_world
9+
integer :: varid, lonid, latid
10+
integer :: i, j, nc,xid,yid
11+
integer :: zid,gwdid,trbid
12+
integer :: ncid,rc
13+
integer :: dimids(2)
14+
integer :: status
15+
16+
integer :: nargs
17+
18+
logical :: doNcar,doGEOS
19+
20+
integer :: ntiles
21+
real, allocatable :: z1d(:)
22+
real(REAL64), allocatable :: xdim(:),ydim(:)
23+
real, allocatable :: a(:,:)
24+
logical :: isCube
25+
26+
nargs = command_argument_count()
27+
28+
doNCAR=.false.
29+
doGEOS=.false.
30+
isCube = .true.
31+
do i=1,nargs
32+
call get_command_argument(i,str)
33+
select case(trim(str))
34+
case ('-i','--input')
35+
call get_command_argument(i+1,fin)
36+
case ('-o','--output')
37+
call get_command_argument(i+1,fout)
38+
doGEOS=.true.
39+
case ('--im')
40+
call get_command_argument(i+1,str)
41+
read(str,'(I10)')im_world
42+
case ('--jm')
43+
call get_command_argument(i+1,str)
44+
read(str,'(I10)')jm_world
45+
isCube = .false.
46+
case ('--ncar')
47+
call get_command_argument(i+1,fncar)
48+
doNCAR=.true.
49+
end select
50+
enddo
51+
52+
if (isCube) jm_world = im_world*6
53+
54+
allocate(a(im_world,jm_world))
55+
open(file=fin,unit=21,form='unformatted')
56+
read(21)a
57+
close(21)
58+
59+
if (doGEOS) then
60+
61+
call check( nf90_create(fout, NF90_NETCDF4,ncid),"error")
62+
call check( nf90_def_dim(ncid,"Xdim",im_world,lonid),"error")
63+
call check( nf90_def_var(ncid,"Xdim",NF90_DOUBLE,(/lonid/),xid),"error")
64+
call check( nf90_put_att(ncid,xid,"units","degrees_east"),"error")
65+
call check( nf90_def_dim(ncid,"Ydim",jm_world,latid),"error")
66+
call check( nf90_def_var(ncid,"Ydim",NF90_DOUBLE,(/latid/),yid),"error")
67+
call check( nf90_put_att(ncid,yid,"units","degrees_north"),"error")
68+
call check( nf90_def_var(ncid,"z",NF90_FLOAT,(/lonid,latid/),varid),"error")
69+
call check( nf90_put_att(ncid,varid,"units","m"),"error")
70+
call check( nf90_put_att(ncid,varid,"long_name","height above sea level"),"error")
71+
72+
call check( nf90_enddef(ncid),"error")
73+
74+
allocate(xdim(im_world),ydim(jm_world))
75+
do i=1,im_world
76+
xdim(i)=i
77+
enddo
78+
do j=1,jm_world
79+
ydim(j)=j
80+
enddo
81+
82+
call check(nf90_put_var(ncid,xid,xdim),"error")
83+
call check(nf90_put_var(ncid,yid,ydim),"error")
84+
call check(nf90_put_var(ncid,varid,a),"error")
85+
call check(nf90_close(ncid),"error")
86+
87+
end if
88+
89+
if (doNCAR) then
90+
91+
ntiles=im_world*jm_world
92+
allocate(z1d(ntiles))
93+
call check( nf90_create(fncar, NF90_NETCDF4,ncid),"error")
94+
call check( nf90_def_dim(ncid,"ncol",ntiles,xid),"error")
95+
call check( nf90_def_var(ncid,"PHIS",NF90_DOUBLE,(/xid/),varid),"error")
96+
call check( nf90_put_att(ncid,varid,"long_name","height"),"error")
97+
call check( nf90_put_att(ncid,varid,"units","m"),"error")
98+
call check( nf90_enddef(ncid),"error")
99+
100+
nc=0
101+
do j=1,jm_world
102+
do i=1,im_world
103+
nc=nc+1
104+
z1d(nc)=a(i,j)
105+
enddo
106+
enddo
107+
108+
call check(nf90_put_var(ncid,varid,z1d),"error")
109+
110+
end if
111+
112+
contains
113+
114+
subroutine check(status,loc)
115+
116+
integer, intent ( in) :: status
117+
character(len=*), intent ( in) :: loc
118+
119+
if(status /= NF90_noerr) then
120+
write (*,*) "Error at ", loc
121+
write (*,*) nf90_strerror(status)
122+
stop "Stopped"
123+
end if
124+
125+
end subroutine check
126+
127+
end program create_example
128+

0 commit comments

Comments
 (0)