Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

write variables to txt document

Dear all,      I want to write some variables to txt document.I add follow to uv3s_update.F90,But it runs very very slow.So what should I do?Thanks! open(nstep,file='/gpfsdata/shaoam/CASE/test01/run/U-A1-'//trim(fname_date)//'.out',form='formatted') open(nstep+1,file='/gpfsdata/shaoam/CASE/test01/run/V-A1-'//trim(fname_date)//'.out',form='formatted') if (mod(nstep,48)==0) then       write(nstep,*) im, jm, km       do k = 1, km          do j = 1, jm            do i = 1, im               write(nstep,*)   u3s(i,j,k)               write(nstep+1,*) v3s(i,j,k)            enddo          enddo       enddo       close(nstep)       close(nstep+1)    end if
 

jedwards

CSEG and Liaisons
Staff member
Write to netcdf using the provided mechanism.  There are output options that will do this. If you really insist on writing a text file get rid of the loops and write them in one step:write(nstep,*) u3s(1:im, 1:jm, 1:km)
 
Thanks for your reply.If I want to write netcdf ,what should I do to use the provided mechanism? Can you explain more detail for me?Thank you very much! 
 

jedwards

CSEG and Liaisons
Staff member
You don't need to modify any files, this is available via the namelistsin user_nl_cam addfincl2 = 'US:I','VS:I'nhtfrq = 0,  1 This will write the instantanious values of US and VS to the second cam history file at each step. See the documentation at http://www.cesm.ucar.edu/models/cesm1.2/cam/docs/ug5_3/ch04.html
 
Thanks for your reply.I need to change code,because I want to update this variables.So I write variables to netcdf files to test them.Can you tell me how to create a new netcdf file and write variables to it by changing code in uv3s_update? What modules I need to invoke?Thank you!
 

hannay

Cecile Hannay
AMWG Liaison
Staff member
You can add new variables to the history files with the subroutines:addfld
and
outfldLook  for "Output an extra variable" at page 38 at
http://www.cesm.ucar.edu/events/tutorials/081114/practical4-hannay.pdf
 
Thanks for your reply.I use addfld and outfld to write five variables in h1 files, but it still runs slowly. So I change these variables in restart filses(test.cam.r.*) and restart every time .It runs faster than that .So I don't understand I only write out 5 variables to h1 files and writing out restart files need many variables ,but it runs more slowerly. Can you help me ? Thank you.
 

jedwards

CSEG and Liaisons
Staff member
There isn't any difference in the mechanism to write a history or a restart file. So I wouldn't expect the performance to be different.  
 
Top