52 #define GetCurrentDir getcwd
59 template<
typename Timg>
68 class_name =
"Netcdf_loader";
78 nc_open_par(
const char *path, NC_NOCLOBBER || NC_NETCDF4, MPI_Comm comm, MPI_Info info,
int *ncidp);
84 subroutine read_var3d(file_name,var_name,var,mpid,inter)
85 ! -----------------------------------------------------------------------
86 ! io : read 3d variable in a netcdf file
87 ! -----------------------------------------------------------------------
94 character(len=*),intent(in) :: file_name,var_name
95 real(rk) :: var(:,:,:)
96 integer(ik) :: varid(1),i
99 integer(ik),parameter :: ndim=3
100 type(mpi_data),optional :: mpid
101 integer(ik) :: dim_len(ndim),dimid(ndim),dim_len_check
102 integer(ik) :: dimt(3),coord(3,2)
103 integer(ik) :: startv(3),countv(3)
104 character(*),optional :: inter
107 if (present(mpid)) then
108 call io_check(nf90_open(path=file_name,&
109 ! mode=IOR(NF90_WRITE,NF90_MPIPOSIX),ncid=ncid,&
110 mode=IOR(NF90_WRITE,NF90_MPIIO),ncid=ncid,&
111 comm=mpid%comm,info=MPI_INFO_NULL))
113 call io_check(nf90_open(path=file_name,mode=nf90_write,ncid=ncid))
117 call io_check(nf90_inq_varid(ncid,var_name,varid(1)))
119 !-> recompute dimensions, start and count if mpi
120 if (present(mpid)) then
121 if (present(inter)) then
122 call md_mpi_global_coord(mpid,dimt,coord,inter=inter)
124 call md_mpi_global_coord(mpid,dimt,coord)
129 !if (dim_len(i)>1) then
137 countv=get_dim_size(var)
140 !-> read field variable
141 ! call io_check(nf90_get_var(ncid,varid(1),var))
143 io_check(nf90_get_var(ncid,varid(1),var,start=startv,count=countv))
146 call io_check(nf90_close(ncid))
148 end subroutine read_var3d