Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

HOW do I open a WRF file in fortran

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.

mirabelle

Member
Hi

It is weird that I can read PSFC varible successful. But read XLONG or XLAT wrong.

My wrfout file message is this:
1.JPG

My fortran code is this:
2.JPG

The run message will tell me :"Segmentation fault (core dumped)"

Is there any wrong?
Thanks
 
The code looks correct. I am suspicious this might be a memory issue. it may be worth trying to unlimit the stacksize before running the program:

In sh/bash, you can run 'ulimit -s unlimited' and in csh/tcsh you can run 'limit stacksize unlimited'

Pease elt me know whether this can solve your problem.
 
Thanks for your reply

sorry for lately reply

It is failed again. Finally, I solved this in matlab.

If you are interested, I can share my input file (447 M) or my domain setting and fortran code with you.
 
Thanks for your kind offer. Yes please share your fortran code just in case some users may have the similar issue.
 
PROGRAM read_nc
USE netcdf

integer,parameter :: nlon=559 ,nlat=409, ntime=365
integer :: ncid2,jj!,iy
real :: temp(nlon,nlat,27)
real :: xlon(nlon),xlat(nlat)
character(len=200) :: path,file2
character(LEN=50) :: dim1,dim2,dim3,num2
INteger(kind=4),dimension(nf90_max_var_dims) :: dimids
integer(kind=4) :: N1,N2,N3,iy,i,j,k
character ye*4
!
file2="wrfinput_d01_2019070100"
write(*,*) 'file2',file2
ierr1=nf90_open(trim(file2),nf90_nowrite,ncid2)

ierr2=nf90_inq_varid(ncid2, 'T', varid)
ierr3=nf90_get_var(ncid2,varid,temp)
write(*,*) ierr1,ierr2,ierr3

write(*,*) "check temp daata"
write(*,*) temp(1:10,1:10,1)
!
ierr4=nf90_inq_varid(ncid2, 'XLONG', varid)
ierr5=nf90_get_var(ncid2,varid,xlon,start=(/1,1,1/),count=(/nlon,nlat/))

write(*,*) ierr4,ierr5

end
 
Hi,
A quick look at your code gives me the impression that some fundamental issues are wrong. For example, xlat and xlon should be 2D array defined as
xlat(nlon,nlat), xlon(nlon,nlat).

I guess you are not familiar with netCDF data and Fortran. I would suggest that you take a look at the website here:
https://www.unidata.ucar.edu/software/netcdf/

In this website you find introduction to netcDF and sample Fortran codes to process netCDF. Hope this is helpful for you.
 
Top