80 #ifndef __NO_4BYTE_REALS 88 #ifndef __NO_4BYTE_REALS 96 #ifndef __NO_4BYTE_REALS 104 #ifndef __NO_4BYTE_REALS 113 integer(kind=ip_intwp_p),
parameter ::
mgrid = 100
118 character(len=ic_med) :: gridname
119 integer(kind=ip_i4_p) :: partid
120 integer(kind=ip_i4_p) :: nx
121 integer(kind=ip_i4_p) :: ny
122 integer(kind=ip_i4_p) :: nc
124 logical :: corner_set
129 logical :: terminated
130 real(kind=ip_realwp_p),
allocatable :: lon(:,:)
131 real(kind=ip_realwp_p),
allocatable :: lat(:,:)
132 real(kind=ip_realwp_p),
allocatable :: clon(:,:,:)
133 real(kind=ip_realwp_p),
allocatable :: clat(:,:,:)
134 real(kind=ip_realwp_p),
allocatable :: angle(:,:)
135 real(kind=ip_realwp_p),
allocatable :: area(:,:)
136 integer(kind=ip_i4_p) ,
allocatable :: mask(:,:)
144 #include <netcdf.inc> 160 integer(kind=ip_intwp_p) :: n
161 character(len=*),
parameter :: subname =
'(oasis_print_grid_data)' 216 integer(kind=ip_intwp_p),
intent (OUT) :: iwrite
219 character(len=*),
parameter :: subname =
'(oasis_start_grids_writing)' 263 character(len=*),
intent (in) :: cgrid
264 integer(kind=ip_intwp_p),
intent (in) :: nx
265 integer(kind=ip_intwp_p),
intent (in) :: ny
266 real(kind=ip_double_p),
intent (in) :: lon(:,:)
267 real(kind=ip_double_p),
intent (in) :: lat(:,:)
268 integer(kind=ip_intwp_p),
intent (in),
optional :: partid
270 integer(kind=ip_intwp_p) :: GRIDID
271 integer(kind=ip_intwp_p) :: ierror
272 integer(kind=ip_intwp_p) :: lnx,lny
273 character(len=*),
parameter :: subname =
'(oasis_write_grid_r8)' 280 write(
nulprt,*) subname,
' size = ',trim(cgrid),nx,ny
285 lnx =
size(lon,dim=1)
286 lny =
size(lon,dim=2)
288 allocate(
prism_grid(gridid)%lon(lnx,lny),stat=ierror)
289 IF (ierror /= 0)
WRITE(
nulprt,*) subname,
' model :',
compid,
' proc :',&
292 lnx =
size(lat,dim=1)
293 lny =
size(lat,dim=2)
295 allocate(
prism_grid(gridid)%lat(lnx,lny),stat=ierror)
296 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
303 if (
present(partid))
then 310 write(
nulprt,*) subname,
' partid = ',trim(cgrid),partid
332 character(len=*),
intent (in) :: cgrid
333 integer(kind=ip_intwp_p),
intent (in) :: nx
334 integer(kind=ip_intwp_p),
intent (in) :: ny
335 real(kind=ip_single_p),
intent (in) :: lon(:,:)
336 real(kind=ip_single_p),
intent (in) :: lat(:,:)
337 integer(kind=ip_intwp_p),
intent (in),
optional :: partid
339 real(kind=ip_double_p),
allocatable :: lon8(:,:)
340 real(kind=ip_double_p),
allocatable :: lat8(:,:)
341 integer(kind=ip_intwp_p) :: ierror
342 integer(kind=ip_intwp_p) :: lpartid
343 integer(kind=ip_intwp_p) :: lnx,lny
344 character(len=*),
parameter :: subname =
'(oasis_write_grid_r4)' 351 write(
nulprt,*) subname,
' size = ',trim(cgrid),nx,ny
355 if (
present(partid))
then 359 write(
nulprt,*) subname,
' partid = ',trim(cgrid),lpartid
362 lnx =
size(lon,dim=1)
363 lny =
size(lon,dim=2)
365 allocate(lon8(lnx,lny),stat=ierror)
366 IF (ierror /= 0)
WRITE(
nulprt,*) subname,
' model :',
compid,
' proc :',&
369 lnx =
size(lat,dim=1)
370 lny =
size(lat,dim=2)
372 allocate(lat8(lnx,lny),stat=ierror)
373 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
399 character(len=*),
intent (in) :: cgrid
400 integer(kind=ip_intwp_p),
intent (in) :: nx
401 integer(kind=ip_intwp_p),
intent (in) :: ny
402 real(kind=ip_double_p),
intent (in) :: angle(:,:)
403 integer(kind=ip_intwp_p),
intent (in),
optional :: partid
405 integer(kind=ip_intwp_p) :: GRIDID
406 integer(kind=ip_intwp_p) :: ierror
407 integer(kind=ip_intwp_p) :: lnx,lny
408 character(len=*),
parameter :: subname =
'(oasis_write_angle_r8)' 415 write(
nulprt,*) subname,
' size = ',trim(cgrid),nx,ny
420 lnx =
size(angle,dim=1)
421 lny =
size(angle,dim=2)
423 allocate(
prism_grid(gridid)%angle(lnx,lny),stat=ierror)
424 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
429 if (
present(partid))
then 436 write(
nulprt,*) subname,
' partid = ',trim(cgrid),partid
457 character(len=*),
intent (in) :: cgrid
458 integer(kind=ip_intwp_p),
intent (in) :: nx
459 integer(kind=ip_intwp_p),
intent (in) :: ny
460 real(kind=ip_single_p),
intent (in) :: angle(:,:)
461 integer(kind=ip_intwp_p),
intent (in),
optional :: partid
463 real(kind=ip_double_p),
allocatable :: angle8(:,:)
464 integer(kind=ip_intwp_p) :: ierror
465 integer(kind=ip_intwp_p) :: lpartid
466 integer(kind=ip_intwp_p) :: lnx,lny
467 character(len=*),
parameter :: subname =
'(oasis_write_angle_r4)' 474 write(
nulprt,*) subname,
' size = ',trim(cgrid),nx,ny
478 if (
present(partid))
then 482 write(
nulprt,*) subname,
' partid = ',trim(cgrid),lpartid
485 lnx =
size(angle,dim=1)
486 lny =
size(angle,dim=2)
488 allocate(angle8(lnx,lny),stat=ierror)
489 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
515 character(len=*),
intent (in) :: cgrid
516 integer(kind=ip_intwp_p),
intent (in) :: nx
517 integer(kind=ip_intwp_p),
intent (in) :: ny
518 integer(kind=ip_intwp_p),
intent (in) :: nc
519 real(kind=ip_double_p),
intent (in) :: clon(:,:,:)
520 real(kind=ip_double_p),
intent (in) :: clat(:,:,:)
521 integer(kind=ip_intwp_p),
intent (in),
optional :: partid
523 integer(kind=ip_intwp_p) :: GRIDID
524 integer(kind=ip_intwp_p) :: ierror
525 integer(kind=ip_intwp_p) :: lnx,lny
526 character(len=*),
parameter :: subname =
'(oasis_write_corner_r8)' 533 write(
nulprt,*) subname,
' size = ',trim(cgrid),nx,ny
538 lnx =
size(clon,dim=1)
539 lny =
size(clon,dim=2)
541 allocate(
prism_grid(gridid)%clon(lnx,lny,nc),stat=ierror)
542 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
545 lnx =
size(clat,dim=1)
546 lny =
size(clat,dim=2)
548 allocate(
prism_grid(gridid)%clat(lnx,lny,nc),stat=ierror)
549 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
556 if (
present(partid))
then 563 write(
nulprt,*) subname,
' partid = ',trim(cgrid),partid
585 character(len=*),
intent (in) :: cgrid
586 integer(kind=ip_intwp_p),
intent (in) :: nx
587 integer(kind=ip_intwp_p),
intent (in) :: ny
588 integer(kind=ip_intwp_p),
intent (in) :: nc
589 real(kind=ip_single_p),
intent (in) :: clon(:,:,:)
590 real(kind=ip_single_p),
intent (in) :: clat(:,:,:)
591 integer(kind=ip_intwp_p),
intent (in),
optional :: partid
593 real(kind=ip_double_p),
allocatable :: clon8(:,:,:),clat8(:,:,:)
594 integer(kind=ip_intwp_p) :: ierror
595 integer(kind=ip_intwp_p) :: lpartid
596 integer(kind=ip_intwp_p) :: lnx,lny
597 character(len=*),
parameter :: subname =
'(oasis_write_corner_r4)' 604 write(
nulprt,*) subname,
' size = ',trim(cgrid),nx,ny
608 if (
present(partid))
then 612 write(
nulprt,*) subname,
' partid = ',trim(cgrid),lpartid
615 lnx =
size(clon,dim=1)
616 lny =
size(clon,dim=2)
618 allocate(clon8(lnx,lny,nc),stat=ierror)
619 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
622 lnx =
size(clat,dim=1)
623 lny =
size(clat,dim=2)
625 allocate(clat8(lnx,lny,nc),stat=ierror)
626 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
654 character(len=*),
intent (in) :: cgrid
655 integer(kind=ip_intwp_p),
intent (in) :: nx
656 integer(kind=ip_intwp_p),
intent (in) :: ny
657 integer(kind=ip_intwp_p),
intent (in) :: mask(:,:)
658 integer(kind=ip_intwp_p),
intent (in),
optional :: partid
660 integer(kind=ip_intwp_p) :: GRIDID
661 integer(kind=ip_intwp_p) :: ierror
662 integer(kind=ip_intwp_p) :: lnx,lny
663 character(len=*),
parameter :: subname =
'(oasis_write_mask)' 670 write(
nulprt,*) subname,
' size = ',trim(cgrid),nx,ny
675 lnx =
size(mask,dim=1)
676 lny =
size(mask,dim=2)
678 allocate(
prism_grid(gridid)%mask(lnx,lny),stat=ierror)
679 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
684 if (
present(partid))
then 691 write(
nulprt,*) subname,
' partid = ',trim(cgrid),partid
713 character(len=*),
intent (in) :: cgrid
714 integer(kind=ip_intwp_p),
intent (in) :: nx
715 integer(kind=ip_intwp_p),
intent (in) :: ny
716 real(kind=ip_double_p),
intent (in) :: area(:,:)
717 integer(kind=ip_intwp_p),
intent (in),
optional :: partid
719 integer(kind=ip_intwp_p) :: GRIDID
720 integer(kind=ip_intwp_p) :: ierror
721 integer(kind=ip_intwp_p) :: lnx,lny
722 character(len=*),
parameter :: subname =
'(oasis_write_area_r8)' 729 write(
nulprt,*) subname,
' size = ',trim(cgrid),nx,ny
734 lnx =
size(area,dim=1)
735 lny =
size(area,dim=2)
737 allocate(
prism_grid(gridid)%area(lnx,lny),stat=ierror)
738 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
743 if (
present(partid))
then 750 write(
nulprt,*) subname,
' partid = ',trim(cgrid),partid
772 character(len=*),
intent (in) :: cgrid
773 integer(kind=ip_intwp_p),
intent (in) :: nx
774 integer(kind=ip_intwp_p),
intent (in) :: ny
775 real(kind=ip_single_p),
intent (in) :: area(:,:)
776 integer(kind=ip_intwp_p),
intent (in),
optional :: partid
778 real(kind=ip_double_p),
allocatable :: area8(:,:)
779 integer(kind=ip_intwp_p) :: ierror
780 integer(kind=ip_intwp_p) :: lpartid
781 integer(kind=ip_intwp_p) :: lnx,lny
782 character(len=*),
parameter :: subname =
'(oasis_write_area_r4)' 789 write(
nulprt,*) subname,
' size = ',trim(cgrid),nx,ny
793 if (
present(partid))
then 797 write(
nulprt,*) subname,
' partid = ',trim(cgrid),lpartid
800 lnx =
size(area,dim=1)
801 lny =
size(area,dim=2)
803 allocate(area8(lnx,lny),stat=ierror)
804 if (ierror /= 0)
write(
nulprt,*) subname,
' model :',
compid,
' proc :',&
827 integer(kind=ip_i4_p) :: n
828 character(len=*),
parameter :: subname =
'(oasis_terminate_grids_writing)' 866 character(len=ic_med) :: filename
867 character(len=ic_med) :: fldname
868 character(len=ic_med) :: cgrid
870 integer(kind=ip_i4_p) :: m,n,n1,g,p
871 integer(kind=ip_i4_p) :: partid
872 integer(kind=ip_i4_p) :: taskid
873 integer(kind=ip_i4_p) :: nx,ny,nc
874 integer(kind=ip_i4_p) :: tnx,tny
875 logical :: partid_grid
876 logical :: active_task
877 logical :: write_task
878 real(kind=ip_realwp_p),
allocatable :: rloc(:,:)
879 real(kind=ip_realwp_p),
allocatable :: rglo(:,:)
880 real(kind=ip_realwp_p),
allocatable :: r3glo(:,:,:)
881 integer(kind=ip_i4_p) ,
allocatable :: iglo(:,:)
882 integer(kind=ip_intwp_p) :: gcnt
884 character(len=ic_med) ,
pointer :: gname0(:),gname(:)
885 character(len=ic_lvar2) ,
pointer :: pname0(:),pname(:)
886 character(len=*),
parameter :: undefined_partname =
'(UnDeFiNeD_PArtnaME)' 887 character(len=*),
parameter :: subname =
'(oasis_write2files)' 904 pname0(n) = undefined_partname
911 linp2=pname0,lout2=pname,spval2=undefined_partname)
922 if (pname(n) /= undefined_partname)
then 927 if (
prism_grid(g)%gridname == gname(n)) found = .true.
929 if (.not. found)
then 930 write(
nulprt,*) subname,
estr,
'grid with partition not defined on all partition tasks: ',trim(gname(n))
960 active_task = .false.
962 if (pname(g) == undefined_partname)
then 963 partid_grid = .false.
970 if (
prism_part(partid)%mpicom /= mpi_comm_null) active_task = .true.
971 if (
prism_part(partid)%rank == taskid) write_task = .true.
972 elseif (partid == -1)
then 973 active_task = .false.
976 write(
nulprt,*) subname,
estr,
'illegal partid for grid:',trim(gname(g)),trim(pname(g)),partid
982 write(
nulprt,*) subname,
' ',trim(gname(g)),
':',trim(pname(g)),
': partid_grid=', &
983 partid_grid,
'active_task=',active_task,
'write_task=',write_task
986 if (active_task)
then 992 allocate(rglo(nx,ny))
999 if (tnx <= 0 .or. tny <= 0)
then 1003 if (
size(
prism_grid(n)%lon,dim=1) /= tnx .or. &
1007 write(
nulprt,*) subname,
estr,
'inconsistent array size lon/lat ',tnx,tny, &
1017 filename =
'grids.nc' 1018 fldname = trim(cgrid)//
'.lon' 1020 if (partid_grid)
then 1032 filename =
'grids.nc' 1033 fldname = trim(cgrid)//
'.lat' 1035 if (partid_grid)
then 1045 if (tnx <= 0 .or. tny <= 0)
then 1049 if (
size(
prism_grid(n)%clon,dim=1) /= tnx .or. &
1053 write(
nulprt,*) subname,
estr,
'inconsistent array size clon/clat ',tnx,tny, &
1063 allocate(r3glo(nx,ny,nc))
1064 filename =
'grids.nc' 1065 fldname = trim(cgrid)//
'.clo' 1067 if (partid_grid)
then 1068 allocate(rloc(tnx,tny))
1072 r3glo(:,:,n1) = rglo(:,:)
1085 filename =
'grids.nc' 1086 fldname = trim(cgrid)//
'.cla' 1088 if (partid_grid)
then 1089 allocate(rloc(tnx,tny))
1093 r3glo(:,:,n1) = rglo(:,:)
1105 if (tnx <= 0 .or. tny <= 0)
then 1109 if (
size(
prism_grid(n)%area,dim=1) /= tnx .or. &
1111 write(
nulprt,*) subname,
estr,
'inconsistent array size area ',tnx,tny, &
1120 filename =
'areas.nc' 1121 fldname = trim(cgrid)//
'.srf' 1123 if (partid_grid)
then 1133 if (tnx <= 0 .or. tny <= 0)
then 1137 if (
size(
prism_grid(n)%angle,dim=1) /= tnx .or. &
1138 size(
prism_grid(n)%angle,dim=2) /= tny )
then 1139 write(
nulprt,*) subname,
estr,
'inconsistent array size angle ',tnx,tny, &
1148 filename =
'grids.nc' 1149 fldname = trim(cgrid)//
'.ang' 1151 if (partid_grid)
then 1161 if (tnx <= 0 .or. tny <= 0)
then 1165 if (
size(
prism_grid(n)%mask,dim=1) /= tnx .or. &
1167 write(
nulprt,*) subname,
estr,
'inconsistent array size mask ',tnx,tny, &
1176 filename =
'masks.nc' 1177 fldname = trim(cgrid)//
'.msk' 1179 allocate(iglo(nx,ny))
1180 if (partid_grid)
then 1181 allocate(rloc(tnx,tny))
1203 deallocate(gname,pname)
1223 character(len=*),
intent (in) :: cgrid
1224 integer(kind=ip_intwp_p),
intent (in) :: nx
1225 integer(kind=ip_intwp_p),
intent (in) :: ny
1226 integer(kind=ip_intwp_p),
intent(out) :: gridID
1228 integer(kind=ip_intwp_p) :: n
1229 character(len=*),
parameter :: subname =
'(oasis_findgrid)' 1237 if (trim(cgrid) == trim(
prism_grid(n)%gridname))
then 1241 write(
nulprt,*) subname,
estr,
'in predefined grid size = ',nx,ny, &
1248 if (gridid < 1)
then 1269 real(kind=ip_realwp_p),
intent(in) :: aloc(:,:)
1270 real(kind=ip_realwp_p),
intent(inout) :: aglo(:,:)
1271 integer(kind=ip_i4_p) ,
intent(in) :: partid
1272 integer(kind=ip_i4_p) ,
intent(in) :: taskid
1274 type(mct_avect) :: avloc,avglo
1275 integer(kind=ip_i4_p) :: i,j,n
1276 integer(kind=ip_i4_p) :: lnx,lny,gnx,gny
1277 character(len=*),
parameter :: subname =
'(oasis_grid_loc2glo)' 1283 if (
prism_part(partid)%mpicom /= mpi_comm_null)
then 1285 lnx =
size(aloc,dim=1)
1286 lny =
size(aloc,dim=2)
1287 gnx =
size(aglo,dim=1)
1288 gny =
size(aglo,dim=2)
1289 call mct_avect_init(avloc,rlist=
'field',lsize=lnx*lny)
1295 avloc%rattr(1,n) = aloc(i,j)
1306 aglo(i,j) = avglo%rattr(1,n)
1309 call mct_avect_clean(avglo)
1312 call mct_avect_clean(avloc)
subroutine, public oasis_write_mask(cgrid, nx, ny, mask, partid)
User interface to set integer mask values.
subroutine, public oasis_terminate_grids_writing()
User interface to indicate user defined grids are done.
subroutine oasis_write_grid_r8(cgrid, nx, ny, lon, lat, partid)
User interface to set latitudes and longitudes for 8 byte reals.
subroutine, public oasis_mpi_chkerr(rcode, string)
Checks MPI error codes and aborts.
Provides a common location for several OASIS variables.
Generic interface to support writing 4 or 8 byte reals.
subroutine oasis_write_corner_r8(cgrid, nx, ny, nc, clon, clat, partid)
User interface to set corner latitudes and longitudes for 8 byte reals.
Provides reusable IO routines for OASIS.
subroutine oasis_write_angle_r8(cgrid, nx, ny, angle, partid)
User interface to set angle for 8 byte reals.
Generic overloaded interface into MPI max reduction.
subroutine, public oasis_write2files()
Interface that actually writes fields to grid files.
type(prism_part_type), dimension(mpart), public prism_part
list of defined partitions
integer(kind=ip_intwp_p) nulprt
Generic overloaded interface into MPI broadcast.
Generic interface to support writing 4 or 8 byte reals.
type(prism_grid_type), dimension(mgrid), save, public prism_grid
array of grid datatypes
subroutine oasis_write_grid_r4(cgrid, nx, ny, lon, lat, partid)
User interface to set latitudes and longitudes for 4 byte reals.
subroutine, public oasis_abort(id_compid, cd_routine, cd_message, file, line, rcode)
OASIS abort method, publically available to users.
subroutine, public oasis_io_write_2dgridint_fromroot(filename, fldname, fld, nx, ny)
Write an integer array named field from the root task to a file.
subroutine oasis_grid_loc2glo(aloc, aglo, partid, taskid)
Local routine that gathers the local array using partition information.
subroutine, public oasis_io_write_2dgridfld_fromroot(filename, fldname, fld, nx, ny)
Write a real array named field from the root task to a file.
integer(kind=ip_i4_p) compid
Generic interface to support writing 4 or 8 byte reals.
subroutine oasis_write_area_r4(cgrid, nx, ny, area, partid)
User interface to set area values for 4 byte reals.
Generic interface to support writing 4 or 8 byte reals.
integer(kind=ip_i4_p) mpi_rank_local
Provides a generic and simpler interface into MPI calls for OASIS.
logical, parameter local_timers_on
subroutine, public oasis_debug_enter(string)
Used when a subroutine is entered, write info to log file at some debug level.
subroutine, public oasis_start_grids_writing(iwrite)
User interface to initialize grid writing.
Generic overloaded interface into MPI min reduction.
subroutine oasis_findgrid(cgrid, nx, ny, gridID)
Local interface to find gridID for a specified grid name.
subroutine, public oasis_mpi_reducelists(linp1, comm, cntout, lout1, callstr, fastcheck, fastcheckout, linp2, lout2, spval2, linp3, lout3, spval3, linp4, lout4, spval4)
Custom method for reducing MPI lists across pes for OASIS.
integer(kind=ip_intwp_p), parameter mgrid
maximum number of grids allowed
subroutine, public oasis_io_write_3dgridfld_fromroot(filename, fldname, fld, nx, ny, nc)
Write a 3d real array named field from the root task to a file.
OASIS partition data and methods.
subroutine, public oasis_print_grid_data()
Print grid information to log file.
integer(kind=ip_intwp_p), save writing_grids_call
OASIS grid data and methods.
subroutine oasis_write_corner_r4(cgrid, nx, ny, nc, clon, clat, partid)
User interface to set corner latitudes and longitudes for 4 byte reals.
subroutine, public oasis_timer_start(timer_label, barrier)
Start a timer.
integer(kind=ip_i4_p) oasis_debug
subroutine, public oasis_timer_stop(timer_label)
Stop a timer.
subroutine oasis_write_area_r8(cgrid, nx, ny, area, partid)
User interface to set area values for 8 byte reals.
character(len= *), parameter, public estr
integer(kind=ip_i4_p) mpi_comm_local
subroutine, public oasis_mpi_barrier(comm, string)
Call MPI_BARRIER for a particular communicator.
subroutine oasis_write_angle_r4(cgrid, nx, ny, angle, partid)
User interface to set angle for 4 byte reals.
integer(kind=ip_intwp_p), public prism_npart
number of partitions defined
logical function, public oasis_io_varexists(filename, fldname)
Checks whether the var fldname is in the file.
Model grid data for creating mapping data and conserving fields.
Performance timer methods.
subroutine, public oasis_debug_exit(string)
Used when a subroutine is exited, write info to log file at some debug level.
integer(kind=ip_intwp_p), save, public prism_ngrid
counter for grids