[Fortran] 纯文本查看 复制代码
program readsilt
implicit none
external read_silt_nc,handle_err
!integer,parameter::lon_2=43200,lat_2=16800,depth_2=4
real SILT_2
character*299 silt_file
integer status
real E
call read_silt_nc(SILT_2,silt_file)
call handle_err(status)
E=1.01*SILT_2**(3.0/5.0)
write(*,*) E
end program
!number 1
subroutine read_silt_nc(SILT_2,silt_file)
implicit none
integer ierr,ncid,varid,len_file
integer,parameter::lon=43200,lat=16800,depth=4
real lon_2(lon)
real lat_2(lat)
real depth_2(depth)
real SILT_2(depth,lat,lon)
!real E
character*299 silt_file
include 'netcdf.inc'
silt_file="/home/iga_qtong/fortran_xcao/gae_c/ap-42/SILT1.nc"
len_file=len_trim(silt_file)
ierr=nf_open(trim(silt_file),nf_write,ncid)
ierr=nf_inq_varid(ncid,'lon',varid)
ierr=nf_get_var_real(ncid,varid,lon_2)
ierr=nf_inq_varid(ncid,'lat',varid)
ierr=nf_get_var_real(ncid,varid,lat_2)
ierr=nf_inq_varid(ncid,'depth',varid)
ierr=nf_get_var_real(ncid,varid,depth_2)
ierr=nf_inq_varid(ncid,'SILT',varid)
ierr=nf_get_var_real(ncid,varid,SILT_2)
write(*,*) 'ierr'
write(*,*) SILT_2(1,31.56247,-179.9958)
end subroutine read_silt_nc
subroutine handle_err(status)
integer status
if (status .NE. nf_noerr) then
write(*,*) nf_strerror(status)
stop 'stopped'
end if
end subroutine handle_err