{"id":157894,"date":"2022-06-06T09:57:55","date_gmt":"2022-06-06T09:57:55","guid":{"rendered":"\/knowledge\/forums\/topic\/how-to-access-the-working-directory-and-the-name-of-the-currently-opened-ad-file-via-user-subroutine-in-autodyn\/"},"modified":"2022-06-06T09:57:55","modified_gmt":"2022-06-06T09:57:55","slug":"how-to-access-the-working-directory-and-the-name-of-the-currently-opened-ad-file-via-user-subroutine-in-autodyn","status":"publish","type":"topic","link":"https:\/\/innovationspace.ansys.com\/knowledge\/forums\/topic\/how-to-access-the-working-directory-and-the-name-of-the-currently-opened-ad-file-via-user-subroutine-in-autodyn\/","title":{"rendered":"How to access the working directory and the name of the currently opened .ad file via User Subroutine in Autodyn?"},"content":{"rendered":"<p>The example below shows how to access the location and the name of the currently opened Autodyn file. The variables FDPRNT and FNID from the module fildef provide the directory and the name. If you compile the example below, launch the usersub exe file, open an Autodyn ad file and execute EXEDIT, the subtoutine will check get the location and the name of the file and open a text file with the same name as the ad file, but with the extension _OUTPUT.log in the working directory and will write the string &#8220;Hello World!&#8221; to text file.<\/p>\n<p>! BEGIN EXAMPLE<\/p>\n<p>      SUBROUTINE EXEDIT3<\/p>\n<p>      USE kindef, ONLY: INT4<br \/>      USE fildef, ONLY : FDPRNT, FNID<br \/>      USE mdpp , ONLY : MYTASK<br \/>      IMPLICIT NONE<\/p>\n<p>      INTEGER(INT4) :: I,J,K,KK, ICHK, IOS, NUNIT<br \/>      CHARACTER(LEN=256) :: FNAME<br \/>      CHARACTER (LEN=5)  ::  TEXT5<br \/>      DO I = 256, 1, -1<br \/>        IF (FNID(I:I)\/=&#8217; &#8216;) EXIT<br \/>      END DO<br \/>      DO J = 256, 1, -1<br \/>        IF (FDPRNT(J:J)\/=&#8217; &#8216;) EXIT<br \/>      END DO<\/p>\n<p>      ! Include the task number in the log file<br \/>      CALL CONITC (MYTASK,TEXT5) <br \/>      DO K = 2,5<br \/>        IF (TEXT5(K:K)==&#8217;$&#8217;) EXIT<br \/>        KK = K<br \/>      END DO<\/p>\n<p>      FNAME = FDPRNT(1:J)\/\/&#8217;\/&#8217;\/\/FNID(1:i)\/\/&#8217;_OUTPUT&#8217;\/\/TEXT5(2:KK)\/\/&#8217;.log&#8217;<br \/>      NUNIT = 78 ! HOPEFULLY FREE UNIT<\/p>\n<p>      OPEN(UNIT=NUNIT,NAME=FNAME,FORM=&#8217;FORMATTED&#8217;, IOSTAT=IOS)<br \/>      WRITE (NUNIT,*,IOSTAT=IOS) &#8216;Hello World!&#8217;<br \/>      CLOSE (NUNIT)<\/p>\n<p>    END SUBROUTINE EXEDIT3<\/p>\n","protected":false},"template":"","class_list":["post-157894","topic","type-topic","status-publish","hentry","topic-tag-autodyn","topic-tag-solver"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_wp_page_template":["default"],"_bbp_last_active_time":["06-06-2022 20:20"],"_bbp_forum_id":["27789"],"_btv_view_count":["1195"],"_bbp_likes_count":["0"]},"test":"articlesansys-com"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics\/157894","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics\/157894\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/media?parent=157894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}