Skip to content

Commit

Permalink
create IMS.rc or JMS.rc directly on run_dir (#740)
Browse files Browse the repository at this point in the history
The present PR is a continuation of #733.
  • Loading branch information
gmao-rreichle authored Mar 21, 2024
2 parents 8f83907 + 644e2e6 commit 6ed3382
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
12 changes: 2 additions & 10 deletions src/Applications/LDAS_App/ldas_setup
Original file line number Diff line number Diff line change
Expand Up @@ -1043,25 +1043,17 @@ class LDASsetup:

# get optimzed NX and IMS
optimized_distribution_file = tempfile.NamedTemporaryFile(delete=False)
tmp_path = os.path.dirname(optimized_distribution_file.name )
print("tmp_path:"+tmp_path)
print ("Optimizing... decomposition of processes.... \n")
cmd = self.bindir + '/preprocess_ldas.x optimize '+ self.inpdir+'/tile.data '+ str(self.rqdRmInp['ntasks_model']) + ' ' + optimized_distribution_file.name
cmd = self.bindir + '/preprocess_ldas.x optimize '+ self.inpdir+'/tile.data '+ str(self.rqdRmInp['ntasks_model']) + ' ' + optimized_distribution_file.name + ' ' + self.rundir
print ("cmd: " + cmd)
print ("IMS.rc or JMS.rc would be generated on " + self.rundir)
sp.call(shlex.split(cmd))
optinxny=self._parseInputFile(optimized_distribution_file.name)
if (int(optinxny['NX']) == 1):
if int(optinxny['NY']) != int(self.rqdRmInp['ntasks_model']):
self.rqdRmInp['ntasks_model']=optinxny['NY']
print ('adjust ntasks_model %d for cubed-sphere grid' % int(self.rqdRmInp['ntasks_model']))

if os.path.isfile( tmp_path+'/IMS.rc') :
shutil.move(tmp_path+'/IMS.rc', self.rundir+'/')
print("move file: " + tmp_path+'/IMS.rc')
if os.path.isfile( tmp_path+'/JMS.rc') :
shutil.move(tmp_path+'/JMS.rc', self.rundir+'/')
print("move file: " + tmp_path+'/JMS.rc')


#os.remove(optimized_distribution_file.name)

Expand Down
2 changes: 1 addition & 1 deletion src/Applications/LDAS_App/preprocess_ldas.F90
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ program main
else if (trim(option) == "optimize") then


call optimize_latlon(arg1,arg2, arg3)
call optimize_latlon(arg1,arg2, arg3, arg4)

else

Expand Down
9 changes: 4 additions & 5 deletions src/Applications/LDAS_App/preprocess_ldas_routines.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2042,13 +2042,14 @@ end subroutine correctEase
! NY: N_proc 1
! JMS.rc IMS.rc

subroutine optimize_latlon(fname_tilefile, N_proc_string, optimized_file)
subroutine optimize_latlon(fname_tilefile, N_proc_string, optimized_file, run_dir)

implicit none

character(*), intent(in) :: fname_tilefile ! file name (with path) of tile file (*.til)
character(*), intent(in) :: N_proc_string ! *string* w/ no. of processors (or tasks), excl. OSERVER tasks
character(*), intent(in) :: optimized_file
character(*), intent(in) :: run_dir

! local variables
integer :: N_proc
Expand Down Expand Up @@ -2287,8 +2288,7 @@ subroutine optimize_latlon(fname_tilefile, N_proc_string, optimized_file)
write(10,'(A)') "GEOSldas.JMS_FILE: JMS.rc"
close(10)

n = index(optimized_file, '/', back=.true.)
JMS_file = optimized_file(1:n)//"JMS.rc"
JMS_file = trim(run_dir)//"/JMS.rc"
open(10,file=JMS_file ,action='write')
write(10,'(I5,I5)') N_proc, maxval(face)
do n=1,N_proc
Expand Down Expand Up @@ -2483,8 +2483,7 @@ subroutine optimize_latlon(fname_tilefile, N_proc_string, optimized_file)
write(10,'(A)') "GEOSldas.IMS_FILE: IMS.rc"
close(10)

n = index(optimized_file, '/', back=.True.)
IMS_file = optimized_file(1:n)//"IMS.rc"
IMS_file = trim(run_dir)//"/IMS.rc"
open(10,file=IMS_file,action='write')
write(10,'(I5)') N_proc
do n=1,N_proc
Expand Down

0 comments on commit 6ed3382

Please sign in to comment.